Commit 55e2ce76 authored by Matija Čupić's avatar Matija Čupić

Revert "Improve cacheable module"

This reverts commit 2ebafdfb
parent 2ebafdfb
...@@ -7,11 +7,11 @@ module RedisCacheable ...@@ -7,11 +7,11 @@ module RedisCacheable
class_methods do class_methods do
def cached_attr_reader(*attributes) def cached_attr_reader(*attributes)
attributes.each do |attribute| attributes.each do |attribute|
unless self.column_names.include?(attribute.to_s) define_method(attribute) do
raise ArgumentError, "`cached_attr_reader` requires the #{self.name}##{attribute} to be a database attribute" unless self.has_attribute?(attribute)
raise ArgumentError, "`cached_attr_reader` requires the #{self.class.name}\##{attribute} attribute to have a database column"
end end
define_method(attribute) do
cached_attribute(attribute) || read_attribute(attribute) cached_attribute(attribute) || read_attribute(attribute)
end end
end end
...@@ -50,9 +50,7 @@ module RedisCacheable ...@@ -50,9 +50,7 @@ module RedisCacheable
if Gitlab.rails5? if Gitlab.rails5?
self.class.type_for_attribute(attribute).cast(value) self.class.type_for_attribute(attribute).cast(value)
else else
ActiveSupport::Deprecation.silence do
self.class.column_for_attribute(attribute).type_cast_from_database(value) self.class.column_for_attribute(attribute).type_cast_from_database(value)
end end
end end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment