summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-05-16 21:23:43 +0200
committerMatija Čupić <matteeyah@gmail.com>2018-05-16 21:23:43 +0200
commit42ab6f8557505595f86604735d8805f879247da8 (patch)
treec744d09e3a4128998631a03679ae4ea1969191f3 /app/models
parent6cc3a07dca635aa61d275eb6803cd986f4c9f967 (diff)
downloadgitlab-ce-42ab6f8557505595f86604735d8805f879247da8.tar.gz
Move attribute casting to #cached_attribute
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/redis_cacheable.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/app/models/concerns/redis_cacheable.rb b/app/models/concerns/redis_cacheable.rb
index 4fdaaddeee7..d40df5ba2d4 100644
--- a/app/models/concerns/redis_cacheable.rb
+++ b/app/models/concerns/redis_cacheable.rb
@@ -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)