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.
468 469 470 471 |
# File 'lib/tuersteher.rb', line 468 def initialize right, negation @negation = negation @rights = [right] end |
Instance Attribute Details
#negation ⇒ Object (readonly)
Returns the value of attribute negation.
466 467 468 |
# File 'lib/tuersteher.rb', line 466 def negation @negation end |
#rights ⇒ Object (readonly)
Returns the value of attribute rights.
466 467 468 |
# File 'lib/tuersteher.rb', line 466 def rights @rights end |
Instance Method Details
#grant?(path_or_model, method, login_ctx) ⇒ Boolean
473 474 475 476 477 478 |
# File 'lib/tuersteher.rb', line 473 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
480 481 482 |
# File 'lib/tuersteher.rb', line 480 def to_s "#{@negation && 'not.'}rights(#{@rights.join(',')})" end |