Sha256: 4113042cbf4dcffdd57404e6a9063623fa77ea8fcef8eadb390ab78172506131

Contents?: true

Size: 655 Bytes

Versions: 1

Compression:

Stored size: 655 Bytes

Contents

module Protector::InheritedResources
  module InstanceMethods
    extend ActiveSupport::Concern

    included do
      alias_method_chain :end_of_association_chain, :protector
    end

    private

    def end_of_association_chain_with_protector
      resource = end_of_association_chain_without_protector
      
      subject = self.class.effective_protector_subject
      
      if subject.kind_of? Symbol
        subject = send subject
      elsif subject
        subject = instance_exec &subject
      end

      if subject && resource.respond_to?(:restrict!)
        resource.restrict! subject
      else
        resource
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
protector-inherited_resources-0.0.1 lib/protector/inherited_resources/instance_methods.rb