title: ruby dynamic dispatch with consecutive method call
body: <p>I am encoutering a small problem while performing dynamic dispatch on some object in Ruby</p>
  
  <p>I want to call a method, but I can only obtain it using multiple calls</p>
  
  <p>i.e : <code>dynamic_string = 'my_object.other_object.this_method'</code></p>
  
  <p>I want to call <code>this_method</code> on <code>other_object</code> that I got from <code>my_object.other_object</code></p>
  
  <p>Here is my MCVE :</p>
  
  <pre><code>class A
      attr_reader :b
      def initialize
          @b = B.new
      end
  end
  class B
      def this
          'i want this dynamically'
      end
  end
  
  a = A.new
  a.b.this # =&gt; 'i want this dynamically'
  dynamic_string = 'b.this'
  a.send(dynamic_string) # =&gt; error below
  </code></pre>
  
  <p><code>NoMethodError: undefined method 'b.this' for #&lt;A:0x000000025598b0 @b=#&lt;B:0x00000002559888&gt;&gt;</code></p>
  
  <p>From what I understand the send method is trying to call the litteral method <code>b.this</code> on the <code>a</code> object.</p>
  
  <p>I know that to make it work I have to make theses consecutive calls :</p>
  
  <p><code>a.send('b').send('this')</code> but I can't figure out how to make this dynamically</p>
  
  <p>How can I achieve consecutive dynamic calls ? ( in this example I only need 2 calls, but I would like a more generic solution if possible, that would work for every number of calls)</p>