Commit eeb955a6 authored by Matija Čupić's avatar Matija Čupić

Revert "Move argument check to cached getter definition class method"

This reverts commit 4e1bb1d1.
parent 4e1bb1d1
...@@ -7,9 +7,9 @@ module RedisCacheable ...@@ -7,9 +7,9 @@ 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|
raise ArgumentError, "Not a database attribute" unless self.attribute_names.include?(attribute.to_s)
define_method(attribute) do define_method(attribute) do
raise ArgumentError, "Not a database attribute" unless self.has_attribute?(attribute)
cached_attribute(attribute) || read_attribute(attribute) cached_attribute(attribute) || read_attribute(attribute)
end end
end end
......
...@@ -11,8 +11,8 @@ describe RedisCacheable do ...@@ -11,8 +11,8 @@ describe RedisCacheable do
cached_value cached_value
end end
def self.attribute_names def has_attribute?(attribute)
%w[name time] attributes.has_key?(attribute)
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