Class: Logux::PolicyCaller

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/logux/policy_caller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action:, meta:) ⇒ PolicyCaller

Returns a new instance of PolicyCaller.



11
12
13
14
# File 'lib/logux/policy_caller.rb', line 11

def initialize(action:, meta:)
  @action = action
  @meta = meta
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



7
8
9
# File 'lib/logux/policy_caller.rb', line 7

def action
  @action
end

#metaObject (readonly)

Returns the value of attribute meta.



7
8
9
# File 'lib/logux/policy_caller.rb', line 7

def meta
  @meta
end

Instance Method Details

#call!Object



16
17
18
19
20
21
22
23
24
# File 'lib/logux/policy_caller.rb', line 16

def call!
  logger.debug('Searching policy for Logux action:' \
               " #{action}, meta: #{meta}")
  policy.public_send("#{action.action_type}?")
rescue Logux::UnknownActionError, Logux::UnknownChannelError => e
  raise e if configuration.verify_authorized

  logger.warn(e)
end