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)
45 46 47 |
# File 'lib/bsm/sso/client/ability.rb', line 45 def user @user end |
Instance Method Details
#applied ⇒ Set
Returns applied roles.
65 66 67 |
# File 'lib/bsm/sso/client/ability.rb', line 65 def applied @applied ||= Set.new end |
#initialize(user) ⇒ Object
Construstor
49 50 51 52 53 54 55 56 57 |
# File 'lib/bsm/sso/client/ability.rb', line 49 def initialize(user) @user = user same_as(:any) @user.roles.each do |name| same_as(name) end same_as(:administrator) if administrator? end |
#same_as(name) ⇒ Object
Runs a role method
71 72 73 74 |
# File 'lib/bsm/sso/client/ability.rb', line 71 def same_as(name) method = :"as__#{scope}__#{name}" send(method) if respond_to?(method, true) end |
#scope ⇒ Symbol
Returns the user scope.
60 61 62 |
# File 'lib/bsm/sso/client/ability.rb', line 60 def scope @scope ||= (user.respond_to?(:kind) && user.kind? ? user.kind.to_sym : :client) end |