Sha256: cf6b382209a1ddf4625e7f575363c8b373e5f3b68765d763065e0ecf2720a8ef

Contents?: true

Size: 903 Bytes

Versions: 1

Compression:

Stored size: 903 Bytes

Contents

module CanTango
  class PermissionEngine < Engine
    autoload_modules :Collector, :Compiler, :Evaluator, :Selector
    autoload_modules :Factory, :Loader, :Parser, :Permission
    autoload_modules :RulesParser, :Store, :YamlStore, :Statements, :Statement

    def initialize ability
      super
    end

    def execute!
      return if !valid?
      debug "Permission Engine executing..."
      permissions.each do |permission|
        permission.evaluate! user
      end
    end

    def engine_name
      :permission
    end

    def valid?
      return false if !valid_mode?
      permissions.empty? ? invalid : true
    end

    def permissions
      permission_factory.build!
    end

    protected

    def invalid
      debug "No permissions found!"
      false
    end

    def permission_factory
      @permission_factory ||= CanTango::PermissionEngine::Factory.new ability
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cantango-0.9.3.2 lib/cantango/permission_engine.rb