Class: CanTango::PermissionEngine

Inherits:
Engine
  • Object
show all
Includes:
Ability::Executor, Ability::RoleHelpers, Ability::UserHelpers
Defined in:
lib/cantango/adapter/moneta.rb,
lib/cantango/permission_engine.rb,
lib/cantango/permission_engine/store.rb,
lib/cantango/permission_engine/loader.rb,
lib/cantango/permission_engine/parser.rb,
lib/cantango/permission_engine/factory.rb,
lib/cantango/permission_engine/compiler.rb,
lib/cantango/permission_engine/selector.rb,
lib/cantango/permission_engine/collector.rb,
lib/cantango/permission_engine/evaluator.rb,
lib/cantango/permission_engine/statement.rb,
lib/cantango/permission_engine/permission.rb,
lib/cantango/permission_engine/statements.rb,
lib/cantango/permission_engine/yaml_store.rb,
lib/cantango/permission_engine/loader/base.rb,
lib/cantango/permission_engine/parser/rule.rb,
lib/cantango/permission_engine/moneta_store.rb,
lib/cantango/permission_engine/parser/regex.rb,
lib/cantango/permission_engine/selector/base.rb,
lib/cantango/permission_engine/parser/default.rb,
lib/cantango/permission_engine/selector/roles.rb,
lib/cantango/permission_engine/selector/users.rb,
lib/cantango/permission_engine/parser/category.rb,
lib/cantango/permission_engine/parser/ownership.rb,
lib/cantango/permission_engine/loader/categories.rb,
lib/cantango/permission_engine/parser/categories.rb,
lib/cantango/permission_engine/selector/licenses.rb,
lib/cantango/permission_engine/loader/permissions.rb,
lib/cantango/permission_engine/parser/permissions.rb,
lib/cantango/permission_engine/parser/relationship.rb,
lib/cantango/permission_engine/selector/user_types.rb,
lib/cantango/permission_engine/selector/role_groups.rb,
lib/cantango/permission_engine/selector/account_types.rb

Defined Under Namespace

Modules: Loader, Parser, Selector Classes: Collector, Compiler, Evaluator, Factory, MonetaStore, Permission, Statement, Statements, Store, YamlStore

Instance Attribute Summary

Attributes inherited from Engine

#ability

Instance Method Summary collapse

Methods included from Ability::UserHelpers

#user, #user_account, #user_key_field

Methods included from Ability::RoleHelpers

#role_groups, #roles

Methods included from Helpers::RoleMethods

#config, #has_role_group_meth, #has_role_meth, #role_groups_list_meth, #roles_list_meth

Methods included from Ability::Executor

#cache, #clear_rules!, #execute!, #rules

Methods included from Ability::CacheHelpers

#cache

Methods included from Helpers::Debug

#debug

Methods inherited from Engine

#execute!

Constructor Details

#initialize(ability) ⇒ PermissionEngine

Returns a new instance of PermissionEngine.



11
12
13
# File 'lib/cantango/permission_engine.rb', line 11

def initialize ability
  super
end

Instance Method Details

#engine_nameObject Also known as: cache_key



21
22
23
# File 'lib/cantango/permission_engine.rb', line 21

def engine_name
  :permission
end

#permissionsObject



30
31
32
# File 'lib/cantango/permission_engine.rb', line 30

def permissions
  permission_factory.build!
end

#permit_rulesObject



15
16
17
18
19
# File 'lib/cantango/permission_engine.rb', line 15

def permit_rules
  permissions.each do |permission|
    permission.evaluate! user
  end
end

#valid?Boolean

Returns:

  • (Boolean)


25
26
27
28
# File 'lib/cantango/permission_engine.rb', line 25

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