Module: Protector::Adapters::ActiveRecord::Association
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/protector/adapters/active_record/association.rb
Overview
Patches ActiveRecord::Associations::SingularAssociation
and ActiveRecord::Associations::CollectionAssociation
Instance Method Summary collapse
-
#build_record_with_protector(*args) ⇒ Object
Forwards protection subject to the new instance.
-
#scope_with_protector(*args) ⇒ Object
Wraps every association with current subject.
Instance Method Details
#build_record_with_protector(*args) ⇒ Object
Forwards protection subject to the new instance
30 31 32 33 |
# File 'lib/protector/adapters/active_record/association.rb', line 30 def build_record_with_protector(*args) return build_record_without_protector(*args) unless protector_subject? build_record_without_protector(*args).restrict!(protector_subject) end |
#scope_with_protector(*args) ⇒ Object
Wraps every association with current subject
23 24 25 26 27 |
# File 'lib/protector/adapters/active_record/association.rb', line 23 def scope_with_protector(*args) scope = scope_without_protector(*args) scope = scope.restrict!(protector_subject) if protector_subject? scope end |