Class: YleTf::Action::TfHooks
- Inherits:
-
Object
- Object
- YleTf::Action::TfHooks
- Defined in:
- lib/yle_tf/action/tf_hooks.rb
Defined Under Namespace
Classes: NoRunner
Instance Method Summary collapse
- #call(env) ⇒ Object
- #hook_env ⇒ Object
- #hook_runner ⇒ Object
-
#initialize(app) ⇒ TfHooks
constructor
A new instance of TfHooks.
- #run_hooks? ⇒ Boolean
Constructor Details
#initialize(app) ⇒ TfHooks
Returns a new instance of TfHooks.
10 11 12 |
# File 'lib/yle_tf/action/tf_hooks.rb', line 10 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/yle_tf/action/tf_hooks.rb', line 14 def call(env) @env = env hook_runner.run('pre') @app.call(env) hook_runner.run('post') end |
#hook_env ⇒ Object
30 31 32 33 34 35 |
# File 'lib/yle_tf/action/tf_hooks.rb', line 30 def hook_env { 'TF_COMMAND' => @env[:tf_command], 'TF_ENV' => @env[:tf_env], } end |
#hook_runner ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/yle_tf/action/tf_hooks.rb', line 22 def hook_runner if run_hooks? TfHook::Runner.new(@env[:config], hook_env) else NoRunner end end |
#run_hooks? ⇒ Boolean
37 38 39 |
# File 'lib/yle_tf/action/tf_hooks.rb', line 37 def run_hooks? !@env[:tf_options][:no_hooks] end |