Sha256: 5f989b2ec0fb9bfaf998c70d6fec7055ff9d3bc862475ae14434805c10d7e1dc
Contents?: true
Size: 1.09 KB
Versions: 76
Compression:
Stored size: 1.09 KB
Contents
module RailsOps::Mixins::Routes extend ActiveSupport::Concern # This class can't be defined at load time of this file as `Rails.application` # would not exist at this point in time. Instead, we're creating and caching # this class on the first call. This is not thread-safe, but the worst case is # that this is performed more than once. def self.container_class @container ||= Class.new do include Rails.application.routes.url_helpers attr_reader :url_options def initialize(url_options) @url_options = url_options end end end # Returns an object that responds to all URL helper methods using the # `url_options` provided with the operation's context. If no URL options are # given, this method will raise an exception. def routes unless @routes if context.url_options.nil? fail RailsOps::Exceptions::RoutingNotAvailable, 'Can not access routes helpers, no url_options given in context.' end @routes = RailsOps::Mixins::Routes.container_class.new(context.url_options) end return @routes end end
Version data entries
76 entries across 76 versions & 1 rubygems