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.2.26 lib/incline/extensions/main_app.rb
incline-0.2.25 lib/incline/extensions/main_app.rb
incline-0.2.24 lib/incline/extensions/main_app.rb
incline-0.2.23 lib/incline/extensions/main_app.rb
incline-0.2.22 lib/incline/extensions/main_app.rb
incline-0.2.21 lib/incline/extensions/main_app.rb
incline-0.2.20 lib/incline/extensions/main_app.rb
incline-0.2.19 lib/incline/extensions/main_app.rb
incline-0.2.18 lib/incline/extensions/main_app.rb
incline-0.2.17 lib/incline/extensions/main_app.rb
incline-0.2.16 lib/incline/extensions/main_app.rb
incline-0.2.15 lib/incline/extensions/main_app.rb
incline-0.2.14 lib/incline/extensions/main_app.rb
incline-0.2.13 lib/incline/extensions/main_app.rb
incline-0.2.12 lib/incline/extensions/main_app.rb
incline-0.2.11 lib/incline/extensions/main_app.rb
incline-0.2.10 lib/incline/extensions/main_app.rb
incline-0.2.9 lib/incline/extensions/main_app.rb
incline-0.2.8 lib/incline/extensions/main_app.rb
incline-0.2.7 lib/incline/extensions/main_app.rb