Class: CanTango::UserAcEngine

Inherits:
Engine
  • Object
show all
Includes:
Ability::Executor, Ability::RoleHelpers, Ability::UserHelpers
Defined in:
lib/cantango/user_ac_engine.rb

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) ⇒ UserAcEngine

Returns a new instance of UserAcEngine.



7
8
9
# File 'lib/cantango/user_ac_engine.rb', line 7

def initialize ability
  super
end

Instance Method Details

#engine_nameObject Also known as: cache_key



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

def engine_name
  :user_ac
end

#permit_rulesObject



11
12
13
14
15
16
17
18
# File 'lib/cantango/user_ac_engine.rb', line 11

def permit_rules
  permissions.each do |permission|
    ability.can permission.action.to_sym, permission.thing_type.constantize do |thing|
      thing.nil? || permission.thing_id.nil? || permission.thing_id == thing.id
    end
  end
  rules << ability_rules if !ability_rules.blank?
end

#valid?Boolean

Returns:

  • (Boolean)


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

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