Module: Tzu::RunMethods
- Defined in:
- lib/tzu/run_methods.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
28
29
30
|
# File 'lib/tzu/run_methods.rb', line 28
def method_missing(method, *args, &block)
@request_klass = args.first if method == :request_object
end
|
Instance Attribute Details
#request_klass ⇒ Object
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
|
#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
|