diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-05-16 21:23:43 +0200 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-05-16 21:23:43 +0200 |
commit | 42ab6f8557505595f86604735d8805f879247da8 (patch) | |
tree | c744d09e3a4128998631a03679ae4ea1969191f3 /app | |
parent | 6cc3a07dca635aa61d275eb6803cd986f4c9f967 (diff) | |
download | gitlab-ce-42ab6f8557505595f86604735d8805f879247da8.tar.gz |
Move attribute casting to #cached_attribute
Diffstat (limited to 'app')
-rw-r--r-- | app/models/concerns/redis_cacheable.rb | 7 |
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) |