Revert "Improve cacheable module"

This reverts commit 2ebafdfb2f
This commit is contained in:
Matija Čupić 2018-05-18 14:34:08 +00:00
parent 2ebafdfb2f
commit 55e2ce762d
1 changed files with 5 additions and 7 deletions

View File

@ -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