Module: Lyra::Interceptors::AssociationInterceptor
- Defined in:
- lib/lyra/interceptors/association_interceptor.rb
Overview
Patches AR association loading to use cached projections when:
- The target model is monitored by Lyra
- Lyra is in event_sourcing mode
- projection_mode is :disabled
This allows belongs_to/has_one associations to work transparently even when the target record only exists in the cache, not the DB.
Defined Under Namespace
Modules: BelongsToAssociationPatch, HasManyAssociationPatch, HasOneAssociationPatch
Class Method Summary collapse
Class Method Details
.install! ⇒ Object
158 159 160 161 162 163 164 165 166 |
# File 'lib/lyra/interceptors/association_interceptor.rb', line 158 def self.install! return if @installed ActiveRecord::Associations::BelongsToAssociation.prepend(BelongsToAssociationPatch) ActiveRecord::Associations::HasOneAssociation.prepend(HasOneAssociationPatch) ActiveRecord::Associations::HasManyAssociation.prepend(HasManyAssociationPatch) @installed = true end |