Class: Ufo::Hooks::Runner
- Inherits:
-
Object
- Object
- Ufo::Hooks::Runner
- Includes:
- Utils::Execute, Utils::Logging
- Defined in:
- lib/ufo/hooks/runner.rb
Instance Attribute Summary collapse
-
#hook ⇒ Object
readonly
Returns the value of attribute hook.
Instance Method Summary collapse
-
#initialize(hook) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Methods included from Utils::Execute
Methods included from Utils::Logging
Constructor Details
#initialize(hook) ⇒ Runner
Returns a new instance of Runner.
7 8 9 10 |
# File 'lib/ufo/hooks/runner.rb', line 7 def initialize(hook) @hook = hook @execute = @hook["execute"] end |
Instance Attribute Details
#hook ⇒ Object (readonly)
Returns the value of attribute hook.
6 7 8 |
# File 'lib/ufo/hooks/runner.rb', line 6 def hook @hook end |
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ufo/hooks/runner.rb', line 12 def run case @execute when String execute(@execute, exit_on_fail: @hook["exit_on_fail"]) when -> (e) { e.respond_to?(:public_instance_methods) && e.public_instance_methods.include?(:call) } executor = @execute.new when -> (e) { e.respond_to?(:call) } executor = @execute else logger.warn "WARN: execute option not set for hook: #{@hook.inspect}" end return unless executor meth = executor.method(:call) case meth.arity when 0 executor.call # backwards compatibility when 1 executor.call(self) else raise "The #{executor} call method definition has been more than 1 arguments and is not supported" end end |