Module: Bsm::Sso::Client::Ability
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/bsm/sso/client/ability.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
- #user ⇒ Object readonly
Instance Method Summary collapse
-
#applied ⇒ Set
Applied roles.
-
#initialize(user) ⇒ Object
Construstor.
-
#same_as(name) ⇒ Object
Runs a role method.
-
#scope ⇒ Symbol
The user scope.
Instance Attribute Details
#user ⇒ Object (readonly)
47 48 49 |
# File 'lib/bsm/sso/client/ability.rb', line 47 def user @user end |
Instance Method Details
#applied ⇒ Set
Returns applied roles.
67 68 69 |
# File 'lib/bsm/sso/client/ability.rb', line 67 def applied @applied ||= Set.new end |
#initialize(user) ⇒ Object
Construstor
51 52 53 54 55 56 57 58 59 |
# File 'lib/bsm/sso/client/ability.rb', line 51 def initialize(user) @user = user @user.roles.each do |name| same_as(name) end same_as(:any) same_as(:administrator) if administrator? end |
#same_as(name) ⇒ Object
Runs a role method
73 74 75 76 |
# File 'lib/bsm/sso/client/ability.rb', line 73 def same_as(name) method = :"as__#{scope}__#{name}" send(method) if respond_to?(method, true) end |
#scope ⇒ Symbol
Returns the user scope.
62 63 64 |
# File 'lib/bsm/sso/client/ability.rb', line 62 def scope @scope ||= (user.respond_to?(:kind) && user.kind? ? user.kind.to_sym : :client) end |