class Object

Public Instance Methods

chain(method_chain, data = nil) click to toggle source

This method is necessary to dynamically chain method calls. The reason this is necessary the data setter initially has no idea of the actual object it's going to be dealing with, particularly because part of its job is to find that object and map a data string to it. Not only this, but that element will have been called on a specific instance of a interface class. With the example provide in the comments below for the `using` method, the following would be the case:

method_chain: warp_factor.set o (object): <WarpTravel:0x007f8b23224218> m (method): warp_factor data: 1

Thus what you end up with is:

<WarpTravel:0x007f8b23224218>.warp_factor.set 1
# File lib/tapestry/extensions/data_setter.rb, line 18
def chain(method_chain, data = nil)
  return self if method_chain.empty?
  method_chain.split('.').inject(self) do |o, m|
    if data.nil?
      o.send(m.intern)
    else
      o.send(m.intern, data)
    end
  end
end