Module: EacCli::Runner::InstanceMethods

Defined in:
lib/eac_cli/runner/instance_methods.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/eac_cli/runner/instance_methods.rb', line 36

def method_missing(method, *args, &block)
  runner_context.runner_missing_method_responder(method).if_callable do |v|
    return v.call(*args, &block)
  end

  super
end

Instance Method Details

#parsedObject



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

def parsed
  @parsed ||= ::EacCli::Parser.new(self.class.runner_definition, runner_context.argv).parsed
end

#program_nameObject



28
29
30
# File 'lib/eac_cli/runner/instance_methods.rb', line 28

def program_name
  runner_context.if_present(&:program_name) || $PROGRAM_NAME
end

#respond_to_missing?(method, include_all = false) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/eac_cli/runner/instance_methods.rb', line 32

def respond_to_missing?(method, include_all = false)
  runner_context.runner_missing_method_responder(method).callable? || super
end

#run_runObject



6
7
8
9
10
11
# File 'lib/eac_cli/runner/instance_methods.rb', line 6

def run_run
  parsed
  run_callbacks(:run) { run }
rescue ::EacCli::Runner::Exit
  # Do nothing
end

#runner_contextObject



13
14
15
16
17
# File 'lib/eac_cli/runner/instance_methods.rb', line 13

def runner_context
  return @runner_context if @runner_context

  raise 'Context was required, but was not set yet'
end

#runner_context=(new_runner_context) ⇒ Object



19
20
21
22
# File 'lib/eac_cli/runner/instance_methods.rb', line 19

def runner_context=(new_runner_context)
  @runner_context = new_runner_context
  @parsed = nil
end