lib/testable/extensions/data_setter.rb
# 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
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.

warp_factor.set
o (object):   
m (method):   warp_factor
data:         1

Thus what you end up with is.


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 . warp_factor . set o ( object ) : m ( method ) : warp_factor data : 1 Thus what you end up with is .
def chain(method_chain, data = nil)
    return self if method_chain.empty?
    method_chain.split('.').inject(self) do |o, m|
      if data.nil?
        o.public_send(m.to_sym)
      else
        o.public_send(m.to_sym, data)
      end
    end
  end
def chain ( method_chain , data = nil ) return self if method_chain . empty? method_chain . split ( '.' ) . inject ( self ) do | o , m | if data . nil? o . public_send ( m . to_sym ) else o . public_send ( m . to_sym , data ) end end end
This method is necessary to dynamically chain method calls.
This method is necessary to dynamically chain method calls .
method_chain
<not_specific>
data
<not_specific>