Class: GraphqlRails::Controller::ActionHooksRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql_rails/controller/action_hooks_runner.rb

Overview

runs before/around/after_action controller hooks

Instance Method Summary collapse

Constructor Details

#initialize(action_name:, controller:) ⇒ ActionHooksRunner

Returns a new instance of ActionHooksRunner.



7
8
9
10
# File 'lib/graphql_rails/controller/action_hooks_runner.rb', line 7

def initialize(action_name:, controller:)
  @action_name = action_name
  @controller = controller
end

Instance Method Details

#call(&block) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/graphql_rails/controller/action_hooks_runner.rb', line 12

def call(&block)
  result = nil
  run_action_hooks(:before)
  run_around_action_hooks { result = controller.instance_exec(&block) }
  run_action_hooks(:after)
  result
end