Sha256: 99f78328fcf846fc352d66eb15c831db80d676715c21d1497b28b7e8dad50875
Contents?: true
Size: 1 KB
Versions: 6
Compression:
Stored size: 1 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
6 entries across 6 versions & 1 rubygems