diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-05-16 22:36:20 +0300 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-05-16 22:36:20 +0300 |
commit | a4b0876b391f0717365cabd78cf9715b64649797 (patch) | |
tree | 2d4e20014c2202348ba17639408c96e3ccc8c202 /app/models/concerns/redis_cacheable.rb | |
parent | 42ab6f8557505595f86604735d8805f879247da8 (diff) |
Add attribute check in cached getter
Diffstat (limited to 'app/models/concerns/redis_cacheable.rb')
-rw-r--r-- | app/models/concerns/redis_cacheable.rb | 2 |
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 |