Module: Lyra::Interceptors::AssociationInterceptor::HasManyAssociationPatch
- Defined in:
- lib/lyra/interceptors/association_interceptor.rb
Instance Method Summary collapse
-
#count_records ⇒ Object
Override count_records to use cache.
-
#empty? ⇒ Boolean
Override empty? directly.
-
#find_target(async: false) ⇒ Object
Rails 8+ passes async: keyword argument to find_target.
-
#size ⇒ Object
Override size to use cache (used by any?, empty?, etc.).
Instance Method Details
#count_records ⇒ Object
Override count_records to use cache
103 104 105 106 107 108 109 |
# File 'lib/lyra/interceptors/association_interceptor.rb', line 103 def count_records if lyra_should_use_cache? lyra_get_cached_relation.count else super end end |
#empty? ⇒ Boolean
Override empty? directly
125 126 127 128 129 130 131 |
# File 'lib/lyra/interceptors/association_interceptor.rb', line 125 def empty? if lyra_should_use_cache? size == 0 else super end end |
#find_target(async: false) ⇒ Object
Rails 8+ passes async: keyword argument to find_target
94 95 96 97 98 99 100 |
# File 'lib/lyra/interceptors/association_interceptor.rb', line 94 def find_target(async: false) if lyra_should_use_cache? lyra_find_target_from_cache else super end end |
#size ⇒ Object
Override size to use cache (used by any?, empty?, etc.)
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/lyra/interceptors/association_interceptor.rb', line 112 def size if lyra_should_use_cache? if loaded? target.size else lyra_get_cached_relation.count end else super end end |