Commit 42ab6f85 authored by Matija Čupić's avatar Matija Čupić

Move attribute casting to #cached_attribute

parent 6cc3a07d
......@@ -8,16 +8,15 @@ module RedisCacheable
def cached_attr_reader(*attributes)
attributes.each do |attribute|
define_method(attribute) do
cached_value = cached_attribute(attribute)
cached_value = cast_value_from_cache(attribute, cached_value) if cached_value
cached_value || read_attribute(attribute)
cached_attribute(attribute) || read_attribute(attribute)
end
end
end
end
def cached_attribute(attribute)
(cached_attributes || {})[attribute]
cached_value = (cached_attributes || {})[attribute]
cast_value_from_cache(attribute, cached_value) if cached_value
end
def cache_attributes(values)
......
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