Class: DeclarativePolicy::Runner::State

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

Instance Method Summary collapse

Constructor Details

#initializeState

Returns a new instance of State.


6
7
8
9
# File 'lib/declarative_policy/runner.rb', line 6

def initialize
  @enabled = false
  @prevented = false
end

Instance Method Details

#enable!Object


11
12
13
# File 'lib/declarative_policy/runner.rb', line 11

def enable!
  @enabled = true
end

#enabled?Boolean

Returns:

  • (Boolean)

15
16
17
# File 'lib/declarative_policy/runner.rb', line 15

def enabled?
  @enabled
end

#pass?Boolean

Returns:

  • (Boolean)

27
28
29
# File 'lib/declarative_policy/runner.rb', line 27

def pass?
  !prevented? && enabled?
end

#prevent!Object


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

def prevent!
  @prevented = true
end

#prevented?Boolean

Returns:

  • (Boolean)

23
24
25
# File 'lib/declarative_policy/runner.rb', line 23

def prevented?
  @prevented
end