Class: Tuersteher::RolesSpecification
- Inherits:
-
Object
- Object
- Tuersteher::RolesSpecification
- Defined in:
- lib/tuersteher.rb
Instance Attribute Summary collapse
-
#negation ⇒ Object
readonly
Returns the value of attribute negation.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
Instance Method Summary collapse
- #grant?(path_or_model, method, login_ctx) ⇒ Boolean
-
#initialize(role, negation) ⇒ RolesSpecification
constructor
A new instance of RolesSpecification.
- #to_s ⇒ Object
Constructor Details
#initialize(role, negation) ⇒ RolesSpecification
Returns a new instance of RolesSpecification.
444 445 446 447 |
# File 'lib/tuersteher.rb', line 444 def initialize role, negation @negation = negation @roles = [role] end |
Instance Attribute Details
#negation ⇒ Object (readonly)
Returns the value of attribute negation.
442 443 444 |
# File 'lib/tuersteher.rb', line 442 def negation @negation end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
442 443 444 |
# File 'lib/tuersteher.rb', line 442 def roles @roles end |
Instance Method Details
#grant?(path_or_model, method, login_ctx) ⇒ Boolean
449 450 451 452 453 454 455 |
# File 'lib/tuersteher.rb', line 449 def grant? path_or_model, method, login_ctx return false if login_ctx.nil? # roles sind or verknüpft rc = @roles.any?{|role| login_ctx.has_role?(role) } rc = !rc if @negation rc end |
#to_s ⇒ Object
457 458 459 460 |
# File 'lib/tuersteher.rb', line 457 def to_s role_s = @roles.size == 1 ? "role(:#{@roles.first})" : "roles(#{@roles.map{|r| ":#{r}"}.join(',')})" "#{@negation && 'not.'}#{role_s}" end |