diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-05-16 21:49:09 +0200 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-05-16 21:49:09 +0200 |
commit | 4e1bb1d1014237df79db6b3cc2beb24228a4b228 (patch) | |
tree | 9419b6d67e9e0957ee39839a607cfd34829a0bba /app/models | |
parent | a4b0876b391f0717365cabd78cf9715b64649797 (diff) | |
download | gitlab-ce-4e1bb1d1014237df79db6b3cc2beb24228a4b228.tar.gz |
Move argument check to cached getter definition class method
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/redis_cacheable.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/concerns/redis_cacheable.rb b/app/models/concerns/redis_cacheable.rb index a8d96f63d7a..bf046c0e333 100644 --- a/app/models/concerns/redis_cacheable.rb +++ b/app/models/concerns/redis_cacheable.rb @@ -7,9 +7,9 @@ module RedisCacheable class_methods do def cached_attr_reader(*attributes) attributes.each do |attribute| - define_method(attribute) do - raise ArgumentError, "Not a database attribute" unless self.has_attribute?(attribute) + raise ArgumentError, "Not a database attribute" unless self.attribute_names.include?(attribute.to_s) + define_method(attribute) do cached_attribute(attribute) || read_attribute(attribute) end end |