Sha256: 3c5a963ab820b97a184ed01388b0cba159622702dff5dac2a8fe661d07e513f6

Contents?: true

Size: 1.03 KB

Versions: 108

Compression:

Stored size: 1.03 KB

Contents

require 'active_support/core_ext/array/extract_options'

module ActionDispatch
  module Routing
    class RoutesProxy #:nodoc:
      include ActionDispatch::Routing::UrlFor

      attr_accessor :scope, :routes
      alias :_routes :routes

      def initialize(routes, scope)
        @routes, @scope = routes, scope
      end

      def url_options
        scope.send(:_with_routes, routes) do
          scope.url_options
        end
      end

      def respond_to?(method, include_private = false)
        super || routes.url_helpers.respond_to?(method)
      end

      def method_missing(method, *args)
        if routes.url_helpers.respond_to?(method)
          self.class.class_eval <<-RUBY, __FILE__, __LINE__ + 1
            def #{method}(*args)
              options = args.extract_options!
              args << url_options.merge((options || {}).symbolize_keys)
              routes.url_helpers.#{method}(*args)
            end
          RUBY
          send(method, *args)
        else
          super
        end
      end
    end
  end
end

Version data entries

108 entries across 104 versions & 8 rubygems

Version Path
actionpack-4.1.16 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.1.16.rc1 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.1.15 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.1.15.rc1 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.1.14.2 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.2.5.2 lib/action_dispatch/routing/routes_proxy.rb
activejob-lock-0.0.2 rails/actionpack/lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.2.5.1 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.1.14.1 lib/action_dispatch/routing/routes_proxy.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/actionpack-4.1.13/lib/action_dispatch/routing/routes_proxy.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/actionpack-4.2.4/lib/action_dispatch/routing/routes_proxy.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/actionpack-4.2.4/lib/action_dispatch/routing/routes_proxy.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/actionpack-4.1.13/lib/action_dispatch/routing/routes_proxy.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/actionpack-4.2.4/lib/action_dispatch/routing/routes_proxy.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/actionpack-4.1.13/lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.1.14 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.2.5 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.2.5.rc2 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.1.14.rc2 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.2.5.rc1 lib/action_dispatch/routing/routes_proxy.rb