Module: CachedAt::AbstractReflection
- Defined in:
- lib/cached_at/reflections/abstract_reflection.rb
Instance Method Summary collapse
- #cache_through_relationship_endpoints ⇒ Object
- #calculate_through_relationship_endpoints ⇒ Object
- #through_relationship_endpoints ⇒ Object
Instance Method Details
#cache_through_relationship_endpoints ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/cached_at/reflections/abstract_reflection.rb', line 4 def cache_through_relationship_endpoints if defined?(Rails) Rails.application.config.cache_classes else true end end |
#calculate_through_relationship_endpoints ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cached_at/reflections/abstract_reflection.rb', line 24 def calculate_through_relationship_endpoints endpoints = [] if self.polymorphic? else self.klass._reflections.each do |name, r| if r.[:cached_at] && r.[:through] && r.[:through] == self.inverse_of&.name endpoints << r end end end endpoints end |
#through_relationship_endpoints ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cached_at/reflections/abstract_reflection.rb', line 12 def through_relationship_endpoints return @through_relationship_endpoints if instance_variable_defined?(:@through_relationship_endpoints) && cache_through_relationship_endpoints @through_relationship_endpoints = if defined?(Rails) Rails.application.reloader.wrap { calculate_through_relationship_endpoints } else calculate_through_relationship_endpoints end @through_relationship_endpoints end |