Class: DeclarativePolicy::Runner::State

Inherits:
Object
  • Object
show all
Defined in:
lib/declarative_policy/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeState

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_conditionsObject (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

Returns:

  • (Boolean)


20
21
22
# File 'lib/declarative_policy/runner.rb', line 20

def enabled?
  @enabled
end

#pass?Boolean

Returns:

  • (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

Returns:

  • (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