Sha256: 951e5b17166da656cd9bbb02d468adfaaa4af62d9dff3c89e7ab95eac83e0599
Contents?: true
Size: 772 Bytes
Versions: 5
Compression:
Stored size: 772 Bytes
Contents
module Protector module Adapters module ActiveRecord # Patches `ActiveRecord::Associations::SingularAssociation` and `ActiveRecord::Associations::CollectionAssociation` module Association extend ActiveSupport::Concern included do # AR 4 has renamed `scoped` to `scope` if method_defined?(:scope) alias_method_chain :scope, :protector else alias_method "scope_without_protector", "scoped" alias_method "scoped", "scope_with_protector" end end # Wraps every association with current subject def scope_with_protector(*args) scope_without_protector(*args).restrict!(owner.protector_subject) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems