Sha256: 096bfc26906844c8b471f2e49c2d02c1c89c26b6827b3c6740a1586c2e22b7f4

Contents?: true

Size: 1.01 KB

Versions: 43

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module EacRailsBase0
  module Patches
    module UrlForPatch
      class << self
        def included(base)
          base.prepend(InstanceMethods)
        end
      end

      module InstanceMethods
        def url_for(options = nil)
          super(options)
        rescue ActionController::UrlGenerationError
          engines_url_for(options)
        end

        private

        def engines_url_for(options)
          ::Rails::Engine.subclasses.each do |engine|
            url = engine_url_for(engine, options)
            return url if url
          end
          raise ActionController::UrlGenerationError, "Options: #{options}"
        end

        def engine_url_for(engine, options)
          engine.routes.url_for(options)
        rescue ActionController::UrlGenerationError
          nil
        end
      end
    end
  end
end

patch = ::EacRailsBase0::Patches::UrlForPatch
target = ::ActionDispatch::Routing::UrlFor
target.prepend(patch) unless target.included_modules.include?(patch)

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
eac_rails_base0-0.68.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.67.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.66.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.65.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.64.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.63.1 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.63.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.62.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.61.1 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.61.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.60.4 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.60.3 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.60.2 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.60.1 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.60.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.59.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.58.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.57.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.56.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.55.3 lib/eac_rails_base0/patches/url_for_patch.rb