Module: Incline::Extensions::MainApp

Defined in:
lib/incline/extensions/main_app.rb

Overview

Makes ‘main_app’ automatically get searched for methods.

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/incline/extensions/main_app.rb', line 11

def self.included(base) # :nodoc:
  base.class_eval do

    # :nodoc:
    alias :incline_mainapp_original_method_missing :method_missing

    def method_missing(method, *args, &block) # :nodoc:
      o_main_app = if respond_to?(:main_app)
                     send(:main_app)
                   else
                     Rails.application.class.routes.url_helpers
                   end
      
      if o_main_app && o_main_app.respond_to?(method)
        return o_main_app.send(method, *args, &block)
      end
      
      incline_mainapp_original_method_missing(method, *args, &block)
    end

  end
end