Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/concerns/redis_cacheable.rb4
-rw-r--r--spec/models/concerns/redis_cacheable_spec.rb4
2 files changed, 4 insertions, 4 deletions
diff --git a/app/models/concerns/redis_cacheable.rb b/app/models/concerns/redis_cacheable.rb
index a8d96f63d7a..bf046c0e333 100644
--- a/app/models/concerns/redis_cacheable.rb
+++ b/app/models/concerns/redis_cacheable.rb
@@ -7,9 +7,9 @@ module RedisCacheable
class_methods do
def cached_attr_reader(*attributes)
attributes.each do |attribute|
- define_method(attribute) do
- raise ArgumentError, "Not a database attribute" unless self.has_attribute?(attribute)
+ raise ArgumentError, "Not a database attribute" unless self.attribute_names.include?(attribute.to_s)
+ define_method(attribute) do
cached_attribute(attribute) || read_attribute(attribute)
end
end
diff --git a/spec/models/concerns/redis_cacheable_spec.rb b/spec/models/concerns/redis_cacheable_spec.rb
index 2da0f33e27b..089ae080b0c 100644
--- a/spec/models/concerns/redis_cacheable_spec.rb
+++ b/spec/models/concerns/redis_cacheable_spec.rb
@@ -11,8 +11,8 @@ describe RedisCacheable do
cached_value
end
- def has_attribute?(attribute)
- attributes.has_key?(attribute)
+ def self.attribute_names
+ %w[name time]
end
end
end