Class: DeclarativePolicy::Runner::State
- Inherits:
-
Object
- Object
- DeclarativePolicy::Runner::State
- Defined in:
- lib/declarative_policy/runner.rb
Instance Attribute Summary collapse
-
#called_conditions ⇒ Object
readonly
Returns the value of attribute called_conditions.
Instance Method Summary collapse
- #enable! ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize ⇒ State
constructor
A new instance of State.
- #pass? ⇒ Boolean
- #prevent! ⇒ Object
- #prevented? ⇒ Boolean
- #register(manifest_condition) ⇒ Object
Constructor Details
#initialize ⇒ State
Returns a new instance of State.
10 11 12 13 14 |
# File 'lib/declarative_policy/runner.rb', line 10 def initialize @enabled = false @prevented = false @called_conditions = Set.new end |
Instance Attribute Details
#called_conditions ⇒ Object (readonly)
Returns the value of attribute called_conditions.
8 9 10 |
# File 'lib/declarative_policy/runner.rb', line 8 def called_conditions @called_conditions end |
Instance Method Details
#enable! ⇒ Object
16 17 18 |
# File 'lib/declarative_policy/runner.rb', line 16 def enable! @enabled = true end |
#enabled? ⇒ Boolean
20 21 22 |
# File 'lib/declarative_policy/runner.rb', line 20 def enabled? @enabled end |
#pass? ⇒ Boolean
32 33 34 |
# File 'lib/declarative_policy/runner.rb', line 32 def pass? !prevented? && enabled? end |
#prevent! ⇒ Object
24 25 26 |
# File 'lib/declarative_policy/runner.rb', line 24 def prevent! @prevented = true end |
#prevented? ⇒ Boolean
28 29 30 |
# File 'lib/declarative_policy/runner.rb', line 28 def prevented? @prevented end |
#register(manifest_condition) ⇒ Object
36 37 38 |
# File 'lib/declarative_policy/runner.rb', line 36 def register(manifest_condition) @called_conditions << manifest_condition.cache_key end |