Class: AccessAllow::AbilitiesManager
- Inherits:
-
Object
- Object
- AccessAllow::AbilitiesManager
- Defined in:
- lib/access_allow/abilities_manager.rb
Instance Method Summary collapse
- #has?(ability_namespace, ability_name) ⇒ Boolean
-
#initialize(user) ⇒ AbilitiesManager
constructor
A new instance of AbilitiesManager.
- #to_a ⇒ Object
Constructor Details
#initialize(user) ⇒ AbilitiesManager
Returns a new instance of AbilitiesManager.
5 6 7 |
# File 'lib/access_allow/abilities_manager.rb', line 5 def initialize(user) @user = user end |
Instance Method Details
#has?(ability_namespace, ability_name) ⇒ Boolean
9 10 11 12 |
# File 'lib/access_allow/abilities_manager.rb', line 9 def has?(ability_namespace, ability_name) namespace = namespaced_context(ability_namespace) namespace[ability_name] end |
#to_a ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/access_allow/abilities_manager.rb', line 14 def to_a @to_a ||= combined_role_and_user_assigned.flat_map do |namespace, abilities| abilities .to_a .each_with_object([]) do |config, arr| ability, permitted = config arr << [namespace, ability.to_sym] if permitted end end end |