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-16 22:36:20 +0300
committerMatija Čupić <matteeyah@gmail.com>2018-05-16 22:36:20 +0300
commita4b0876b391f0717365cabd78cf9715b64649797 (patch)
tree2d4e20014c2202348ba17639408c96e3ccc8c202 /app/models/concerns/redis_cacheable.rb
parent42ab6f8557505595f86604735d8805f879247da8 (diff)
Add attribute check in cached getter
Diffstat (limited to 'app/models/concerns/redis_cacheable.rb')
-rw-r--r--app/models/concerns/redis_cacheable.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/app/models/concerns/redis_cacheable.rb b/app/models/concerns/redis_cacheable.rb
index d40df5ba2d4..a8d96f63d7a 100644
--- a/app/models/concerns/redis_cacheable.rb
+++ b/app/models/concerns/redis_cacheable.rb
@@ -8,6 +8,8 @@ module RedisCacheable
def cached_attr_reader(*attributes)
attributes.each do |attribute|
define_method(attribute) do
+ raise ArgumentError, "Not a database attribute" unless self.has_attribute?(attribute)
+
cached_attribute(attribute) || read_attribute(attribute)
end
end