Sha256: 0666c03a14fc2d1322283da98b9e8eb2e14efd8afd0e8b41f5983f3dc97a6421

Contents?: true

Size: 954 Bytes

Versions: 3

Compression:

Stored size: 954 Bytes

Contents

module CanTango
  class PermitEngine < Engine
    autoload_modules :Builder, :Compatibility, :Executor
    autoload_modules :Factory, :Finder, :Loaders, :Util, :RoleMatcher

    def initialize ability
      super
    end

    def execute!
      # CanTango.config.permits.clear_executed! # should there be an option clear before each execution?
      permits.each do |permit|
        CanTango.config.permits.was_executed(permit, ability) if CanTango.config.debug.on?
        break if permit.execute == :break
      end
    end

    # by default, only execute permits for which the user
    # has a role or a role group
    # also execute any permit marked as special
    def permits
      @permits ||= permit_factory.build!
    end

    def permit_class_names
      @permit_class_names ||= permits.map{|p| p.class.to_s}
    end

    protected

    def permit_factory
      @permit_factory ||= CanTango::PermitEngine::Factory.new ability
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cantango-0.8.6.2 lib/cantango/permit_engine.rb
cantango-0.8.6.1 lib/cantango/permit_engine.rb
cantango-0.8.6 lib/cantango/permit_engine.rb