Module: Tzu::RunMethods

Defined in:
lib/tzu/run_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#request_klassObject (readonly)

Returns the value of attribute request_klass.



3
4
5
# File 'lib/tzu/run_methods.rb', line 3

def request_klass
  @request_klass
end

Instance Method Details

#command_name(value = nil) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/tzu/run_methods.rb', line 20

def command_name(value = nil)
  if value.nil?
    @name ||= name.underscore.to_sym
  else
    @name = (value.presence && value.to_sym)
  end
end

#get_instance(*context) ⇒ Object



15
16
17
18
# File 'lib/tzu/run_methods.rb', line 15

def get_instance(*context)
  method = respond_to?(:build) ? :build : :new
  send(method, *context)
end

#request_object(klass) ⇒ Object



28
29
30
# File 'lib/tzu/run_methods.rb', line 28

def request_object(klass)
  @request_klass = klass
end

#run(params, *context, &block) ⇒ Object



5
6
7
8
9
# File 'lib/tzu/run_methods.rb', line 5

def run(params, *context, &block)
  result = get_instance(*context).run(params)
  return result.handle(&block) if block
  result
end

#run!(params, *context) ⇒ Object



11
12
13
# File 'lib/tzu/run_methods.rb', line 11

def run!(params, *context)
  get_instance(*context).run!(params)
end