Sha256: 1199ac30951d88121034b15f9011aab62a7b6dd9f9c445e9793c1643b02c639a
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
module Protector module CanCan module Resource extend ActiveSupport::Concern included do alias_method_chain :resource_base, :protector alias_method_chain :load_collection, :protector alias_method_chain :load_collection?, :protector end def resource_base_with_protector resource = resource_base_without_protector if resource_protectable? resource resource.restrict!(current_ability.protector_subject) else resource end end def load_collection_with_protector resource = resource_base if resource_protectable? resource resource else load_collection_without_protector end end def load_collection_with_protector? if resource_protectable? resource_base true else load_collection_without_protector? end end private def resource_protectable?(resource) resource.respond_to?(:restrict!) && current_ability.protector_subject? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
protector-cancan-0.1.1 | lib/protector/cancan/resource.rb |