Class: Crew::Task::Arguments::Proxy
- Inherits:
-
Object
- Object
- Crew::Task::Arguments::Proxy
- Defined in:
- lib/crew/task/arguments.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
Instance Method Summary collapse
-
#initialize(task, params, block) ⇒ Proxy
constructor
A new instance of Proxy.
- #method_missing(name, *args) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(task, params, block) ⇒ Proxy
Returns a new instance of Proxy.
50 51 52 |
# File 'lib/crew/task/arguments.rb', line 50 def initialize(task, params, block) @task, @params, @block = task, params, block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/crew/task/arguments.rb', line 54 def method_missing(name, *args) if @params.key?(name.to_s) @params[name.to_s].is_a?(Proc) ? @task.instance_eval(&@params[name.to_s]) : @params[name.to_s] else super end end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
48 49 50 |
# File 'lib/crew/task/arguments.rb', line 48 def block @block end |
Instance Method Details
#to_s ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/crew/task/arguments.rb', line 62 def to_s @params.empty? ? "" : "(" + @params.map do |k, v| val = v.inspect if val.size > 50 val = val[0..22] + "..." + val[-22..-1] end "#{k}=#{val}" end.join(" ") + ")" end |