Method: Such::Thing.do_method

Defined in:
lib/such/thing.rb

.do_method(obj, mthd, *args) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/such/thing.rb', line 85

def self.do_method(obj, mthd, *args)
  Thing.trace_method(obj, mthd, args) if $VERBOSE
  m = obj.method(mthd)
  begin
    m.call(*args)
  rescue ArgumentError, TypeError
    # Assume user meant to iterate. Note that the heuristic is not perfect.
    $stderr.puts "# Iterated Method #{mthd}." if $VERBOSE
    [*args].each{m.call(*_1)}
  end
end