summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-05-18 14:34:08 +0000
committerMatija Čupić <matteeyah@gmail.com>2018-05-18 14:34:08 +0000
commit55e2ce762d52e680b45c9b87a238f993485f2866 (patch)
tree4c141b5ce455cb5d70dabd00c45c1d2462ca42d5
parent2ebafdfb2f026580153fd2cf50f4b6b7ab3a0344 (diff)
downloadgitlab-ce-55e2ce762d52e680b45c9b87a238f993485f2866.tar.gz
This reverts commit 2ebafdfb2f026580153fd2cf50f4b6b7ab3a0344
-rw-r--r--app/models/concerns/redis_cacheable.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/app/models/concerns/redis_cacheable.rb b/app/models/concerns/redis_cacheable.rb
index 53f022e2b35..b5425295130 100644
--- a/app/models/concerns/redis_cacheable.rb
+++ b/app/models/concerns/redis_cacheable.rb
@@ -7,11 +7,11 @@ module RedisCacheable
class_methods do
def cached_attr_reader(*attributes)
attributes.each do |attribute|
- unless self.column_names.include?(attribute.to_s)
- raise ArgumentError, "`cached_attr_reader` requires the #{self.name}##{attribute} to be a database attribute"
- end
-
define_method(attribute) do
+ unless self.has_attribute?(attribute)
+ raise ArgumentError, "`cached_attr_reader` requires the #{self.class.name}\##{attribute} attribute to have a database column"
+ end
+
cached_attribute(attribute) || read_attribute(attribute)
end
end
@@ -50,9 +50,7 @@ module RedisCacheable
if Gitlab.rails5?
self.class.type_for_attribute(attribute).cast(value)
else
- ActiveSupport::Deprecation.silence do
- self.class.column_for_attribute(attribute).type_cast_from_database(value)
- end
+ self.class.column_for_attribute(attribute).type_cast_from_database(value)
end
end
end