Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-05-08 13:20:54 +0300
committerMatija Čupić <matteeyah@gmail.com>2018-05-08 13:20:54 +0300
commit7be65f5d8fd7789b6f630ea04b7bcec8847ab436 (patch)
treeaa6ca735446ed4fc6ce8a9b0d3ec1b01082da5e9 /app/models/concerns/redis_cacheable.rb
parentc8bfb3e418b0dcce8b3f3bec91bb2ae64f0fe19d (diff)
Add cached_attr_time_reader to RedisCacheable
Diffstat (limited to 'app/models/concerns/redis_cacheable.rb')
-rw-r--r--app/models/concerns/redis_cacheable.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/concerns/redis_cacheable.rb b/app/models/concerns/redis_cacheable.rb
index b889f4202dc..0dd15734eae 100644
--- a/app/models/concerns/redis_cacheable.rb
+++ b/app/models/concerns/redis_cacheable.rb
@@ -12,6 +12,15 @@ module RedisCacheable
end
end
end
+
+ def cached_attr_time_reader(*attributes)
+ attributes.each do |attribute|
+ define_method("#{attribute}") do
+ cached_value = cached_attribute(attribute)
+ cached_value ? Time.zone.parse(cached_value) : read_attribute(attribute)
+ end
+ end
+ end
end
def cached_attribute(attribute)