Module: Policy::Controller

Defined in:
lib/adapters/controller.rb

Instance Method Summary collapse

Instance Method Details

#authorize(result = false) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/adapters/controller.rb', line 5

def authorize result = false
  if (block_given? ? yield : result)
    @_is_policy_authorized = true
  else
    Policy.error('Authorize did not pass truthy value')
  end
end

#is_authorized!Object



17
18
19
20
21
22
23
# File 'lib/adapters/controller.rb', line 17

def is_authorized!
  if is_authorized?
    true
  else
    Policy.error('Request is not authorized!')
  end
end

#is_authorized?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/adapters/controller.rb', line 13

def is_authorized?
  @_is_policy_authorized == true
end