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.55.2 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.55.1 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.55.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.54.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.53.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.52.3 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.52.2 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.52.1 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.52.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.51.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.50.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.49.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.48.1 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.48.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.47.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.46.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.45.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.44.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.43.0 lib/eac_rails_base0/patches/url_for_patch.rb
eac_rails_base0-0.42.0 lib/eac_rails_base0/patches/url_for_patch.rb