Sha256: d005f1bd213be3ecbec4561ab6608cd46ee360107a9fcb1b1d38ad773785e99b

Contents?: true

Size: 1.09 KB

Versions: 45

Compression:

Stored size: 1.09 KB

Contents

require 'action_controller'
require 'action_mailer'
require 'action_view'

module Incline::Extensions

  ##
  # Makes 'main_app' automatically get searched for methods.
  module MainApp

    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

  end

end

ActionController::Base.include Incline::Extensions::MainApp
ActionMailer::Base.include Incline::Extensions::MainApp
ActionView::Base.include Incline::Extensions::MainApp
ActiveSupport::TestCase.include Incline::Extensions::MainApp

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
incline-0.3.14 lib/incline/extensions/main_app.rb
incline-0.3.13 lib/incline/extensions/main_app.rb
incline-0.3.12 lib/incline/extensions/main_app.rb
incline-0.3.11 lib/incline/extensions/main_app.rb
incline-0.3.10 lib/incline/extensions/main_app.rb
incline-0.3.9 lib/incline/extensions/main_app.rb
incline-0.3.8 lib/incline/extensions/main_app.rb
incline-0.3.7 lib/incline/extensions/main_app.rb
incline-0.3.6 lib/incline/extensions/main_app.rb
incline-0.3.5 lib/incline/extensions/main_app.rb
incline-0.3.4 lib/incline/extensions/main_app.rb
incline-0.3.3 lib/incline/extensions/main_app.rb
incline-0.3.2 lib/incline/extensions/main_app.rb
incline-0.3.1 lib/incline/extensions/main_app.rb
incline-0.3.0 lib/incline/extensions/main_app.rb
incline-0.2.36 lib/incline/extensions/main_app.rb
incline-0.2.35 lib/incline/extensions/main_app.rb
incline-0.2.34 lib/incline/extensions/main_app.rb
incline-0.2.28 lib/incline/extensions/main_app.rb
incline-0.2.27 lib/incline/extensions/main_app.rb