Sha256: fc71c9f2d7b8e7a0fd69bfe58c160c3bc5efeb46016e7fab4b67650782a72e7e

Contents?: true

Size: 1.03 KB

Versions: 53

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, helpers)
        @routes, @scope = routes, scope
        @helpers = helpers
      end

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

      def respond_to?(method, include_private = false)
        super || @helpers.respond_to?(method)
      end

      def method_missing(method, *args)
        if @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)
              @helpers.#{method}(*args)
            end
          RUBY
          send(method, *args)
        else
          super
        end
      end
    end
  end
end

Version data entries

53 entries across 52 versions & 5 rubygems

Version Path
actionpack-4.2.11.3 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.2.11.2 lib/action_dispatch/routing/routes_proxy.rb
actionpack-5.0.7.2 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.2.11.1 lib/action_dispatch/routing/routes_proxy.rb
actionpack-5.0.7.1 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.2.11 lib/action_dispatch/routing/routes_proxy.rb
actionpack-5.0.7 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.2.10 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.2.10.rc1 lib/action_dispatch/routing/routes_proxy.rb
actionpack-5.0.6 lib/action_dispatch/routing/routes_proxy.rb
actionpack-5.0.6.rc1 lib/action_dispatch/routing/routes_proxy.rb
actionpack-5.0.5 lib/action_dispatch/routing/routes_proxy.rb
actionpack-5.0.5.rc2 lib/action_dispatch/routing/routes_proxy.rb
actionpack-5.0.5.rc1 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.2.9 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.2.9.rc2 lib/action_dispatch/routing/routes_proxy.rb
actionpack-5.0.4 lib/action_dispatch/routing/routes_proxy.rb
actionpack-5.0.4.rc1 lib/action_dispatch/routing/routes_proxy.rb
actionpack-4.2.9.rc1 lib/action_dispatch/routing/routes_proxy.rb
actionpack-5.0.3 lib/action_dispatch/routing/routes_proxy.rb