Class: Dashy::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/dashy/runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.config_and_run {|runner| ... } ⇒ Object

Yields:

  • (runner)


10
11
12
13
14
# File 'lib/dashy/runner.rb', line 10

def self.config_and_run
  runner = Dashy::Runner.new
  yield runner
  runner.run
end

.run_and_report_status_for(&block) ⇒ Object



4
5
6
7
8
# File 'lib/dashy/runner.rb', line 4

def self.run_and_report_status_for &block
  Dashy::Runner.config_and_run do |runner|
    runner.block_to_run &block
  end
end

Instance Method Details

#block_to_run(&block) ⇒ Object



16
17
18
# File 'lib/dashy/runner.rb', line 16

def block_to_run &block
  @block_to_run = block
end

#runObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dashy/runner.rb', line 28

def run
  raise 'Please before running Dashy you need to set the block_to_run' unless @block_to_run
  begin
    response = @block_to_run.call
    Dashy::RestInterface.report_status(({:success => valid_response_after_calling_block?(response)}).merge(extra_options))
    return response
  rescue StandardError => e
    Dashy::RestInterface.report_status(({:success => false}).merge(extra_options))
    raise
  end
end

#valid_response?(&block) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/dashy/runner.rb', line 24

def valid_response? &block
  @valid_response_block = block
end

#with_options(options = {}) ⇒ Object



20
21
22
# File 'lib/dashy/runner.rb', line 20

def with_options options = {}
  @options = options
end