Class: CanTango::PermitEngine::Executor::Base

Inherits:
Abstract
  • Object
show all
Includes:
Helpers::RoleMethods
Defined in:
lib/cantango/permit_engine/executor/base.rb

Instance Attribute Summary

Attributes inherited from Abstract

#permit

Instance Method Summary collapse

Methods included from Helpers::RoleMethods

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

Methods inherited from Abstract

#initialize, #permit?

Constructor Details

This class inherits a constructor from CanTango::PermitEngine::Executor::Abstract

Instance Method Details

#execute!Object

execute the permit



6
7
8
9
# File 'lib/cantango/permit_engine/executor/base.rb', line 6

def execute!
  role_execution
  #role_group_execution
end

#permit_for_user_group?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/cantango/permit_engine/executor/base.rb', line 25

def permit_for_user_group?
  subject_in_role_group? || false
end

#permit_for_user_role?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/cantango/permit_engine/executor/base.rb', line 16

def permit_for_user_role?
  subject_in_role? || role == :any
end

#role_executionObject

only execute the permit if the user has the role of the permit or is for any role



12
13
14
# File 'lib/cantango/permit_engine/executor/base.rb', line 12

def role_execution
  permit? if permit_for_user_role? || permit_for_user_group?
end

#role_group_executionObject



20
21
22
23
# File 'lib/cantango/permit_engine/executor/base.rb', line 20

def role_group_execution
  # could also use #user.is_member_of?
  permit? if permit_for_user_group?
end