Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4e1bb1d1
Commit
4e1bb1d1
authored
May 16, 2018
by
Matija Čupić
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move argument check to cached getter definition class method
parent
a4b0876b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
app/models/concerns/redis_cacheable.rb
app/models/concerns/redis_cacheable.rb
+2
-2
spec/models/concerns/redis_cacheable_spec.rb
spec/models/concerns/redis_cacheable_spec.rb
+2
-2
No files found.
app/models/concerns/redis_cacheable.rb
View file @
4e1bb1d1
...
...
@@ -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
...
...
spec/models/concerns/redis_cacheable_spec.rb
View file @
4e1bb1d1
...
...
@@ -11,8 +11,8 @@ describe RedisCacheable do
cached_value
end
def
has_attribute?
(
attribute
)
attributes
.
has_key?
(
attribute
)
def
self
.
attribute_names
%w[name time]
end
end
end
...
...
Alain Takoudjou
@alain.takoudjou
mentioned in commit
eeb955a6
·
Aug 21, 2018
mentioned in commit
eeb955a6
mentioned in commit eeb955a66d2410d7117737ecd1b33b0cfe67327b
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment