title: a more elegant way to do this?
body: <p>Sorry that I haven't made the title very clear but I honestly can't work out how to phrase my question any better; if some one can think of a better title, then please by all means change it.</p>
  
  <p>Take a look at the following example:</p>
  
  <pre><code>module Foo
    def method(value)
      Bar.instance_exec(self.method(value))
    end
  
    class Bar
  
      def self.method(value)
        print value
      end
  
    end
  end
  </code></pre>
  
  <p>Is that the only way to make is so  <code>Bar</code>'s <code>method</code> is available within the namespace of <code>Foo</code> without the need to call <code>Bar</code> or is there a more elegant way to do this? Perhaps method_missing might work but again, a bit cumbersome.</p>
  
  <p>EDIT:
  Further example</p>
  
  <pre><code>Module Foo
    class SomeClassController &lt; ApplicationController
  
     def index
      method(@user.id) #instead of Bar.method(@user.id)
    end
  
  end
  </code></pre>
  
  <p>I'm building an engine but I don't want to have to refer to <code>Engine</code> every time I want to use a method from it that should be available everywhere within that Main Name Space (<code>Foo</code> in this instance) AS there more like utility methods BUT they need to be done within the scope of <code>Engine</code>.</p>
  
  <p>EDIT:
  Turns out I wasn't using the code correctly</p>
  
  <pre><code>module Foo
    def method(value)
      return Bar.instance_exec(value) { |v| return self.method(value)}
    end
  
    class Bar
  
      def self.method(value)
        return (value + 59)
      end
  
    end
  end
  </code></pre>
  
  <p>will the method inside of the block of <code>instance_exec</code> return outside of it so that <code>def method</code> within <code>module Foo</code> will return the correct value.</p>
  
  <p>EDIT: I realise it is kind of vague but trust me when I say that <code>instance_exec</code> is exactly what I was searching for, that and <code>instance_exec</code> does in deed return outside of it's execution block. </p>