Module: Protector::Adapters::ActiveRecord::Preloader::Association
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/protector/adapters/active_record/preloader.rb
Overview
Patches ActiveRecord::Associations::Preloader::Association
Instance Method Summary collapse
-
#protector_subject ⇒ Object
Gets current subject of preloading association.
-
#scope_with_protector(*args) ⇒ Object
Restricts preloading association scope with subject of the owner.
Instance Method Details
#protector_subject ⇒ Object
Gets current subject of preloading association
20 21 22 23 24 |
# File 'lib/protector/adapters/active_record/preloader.rb', line 20 def protector_subject # Owners are always loaded from the single source # having same protector_subject owners.first.protector_subject end |
#scope_with_protector(*args) ⇒ Object
Restricts preloading association scope with subject of the owner
27 28 29 30 31 32 |
# File 'lib/protector/adapters/active_record/preloader.rb', line 27 def scope_with_protector(*args) return scope_without_protector unless protector_subject @meta ||= klass..evaluate(klass, protector_subject) scope_without_protector.merge(@meta.relation) end |