Sha256: 9870a9f41c6f32165afbffbc72086a3de42f63fe70b5b804b9743675c065d5af

Contents?: true

Size: 546 Bytes

Versions: 1

Compression:

Stored size: 546 Bytes

Contents

module Protector
  module Adapters
    module ActiveRecord
      module Association
        extend ActiveSupport::Concern

        included do
          if method_defined?(:scope)
            alias_method_chain :scope, :protector
          else
            alias_method "scope_without_protector", "scoped"
            alias_method "scoped", "scope_with_protector"
          end
        end

        def scope_with_protector(*args)
          scope_without_protector(*args).restrict!(owner.protector_subject)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
protector-0.1.0 lib/protector/adapters/active_record/association.rb