Skip to content

Commit

Permalink
Refactor IdentityCache::Cached::Reference::HasOne for consistency
Browse files Browse the repository at this point in the history
Also, avoids the redundant association lookup
  • Loading branch information
dylanahsmith committed Apr 3, 2020
1 parent 0791ba7 commit 3983507
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/identity_cache/cached/reference/has_one.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def #{cached_id_name}
end
def #{cached_accessor_name}
association_klass = association(:#{name}).klass
if association_klass.should_use_cache? && !association(:#{name}).loaded?
assoc = association(:#{name})
if assoc.klass.should_use_cache? && !assoc.loaded?
#{records_variable_name} ||= #{reflection.class_name}.fetch(#{cached_id_name}) if #{cached_id_name}
else
#{name}
Expand Down

0 comments on commit 3983507

Please sign in to comment.