Class: Tuersteher::RightSpecification
- Inherits:
-
Object
- Object
- Tuersteher::RightSpecification
- Defined in:
- lib/tuersteher.rb
Instance Attribute Summary collapse
-
#negation ⇒ Object
readonly
Returns the value of attribute negation.
-
#rights ⇒ Object
readonly
Returns the value of attribute rights.
Instance Method Summary collapse
- #grant?(path_or_model, method, login_ctx) ⇒ Boolean
-
#initialize(right, negation) ⇒ RightSpecification
constructor
A new instance of RightSpecification.
- #to_s ⇒ Object
Constructor Details
#initialize(right, negation) ⇒ RightSpecification
Returns a new instance of RightSpecification.
466 467 468 469 |
# File 'lib/tuersteher.rb', line 466 def initialize right, negation @negation = negation @rights = [right] end |
Instance Attribute Details
#negation ⇒ Object (readonly)
Returns the value of attribute negation.
464 465 466 |
# File 'lib/tuersteher.rb', line 464 def negation @negation end |
#rights ⇒ Object (readonly)
Returns the value of attribute rights.
464 465 466 |
# File 'lib/tuersteher.rb', line 464 def rights @rights end |
Instance Method Details
#grant?(path_or_model, method, login_ctx) ⇒ Boolean
471 472 473 474 475 476 |
# File 'lib/tuersteher.rb', line 471 def grant? path_or_model, method, login_ctx return false if login_ctx.nil? rc =@rights.any?{|right| login_ctx.has_right?(right) } rc = !rc if @negation rc end |
#to_s ⇒ Object
478 479 480 |
# File 'lib/tuersteher.rb', line 478 def to_s "#{@negation && 'not.'}rights(#{@rights.join(',')})" end |