module Cell::UrlOptions

Public Class Methods

prepended(cls) click to toggle source
# File lib/cell/url_options.rb, line 3
def self.prepended(cls)
  cls.after_set  :change_url_options, if: :has_cell_host?
  cls.around_use :change_url_options, if: :has_cell_host?
end

Public Instance Methods

has_cell_host?() click to toggle source
# File lib/cell/url_options.rb, line 8
def has_cell_host?
  respond_to?(:cell_host)
end

Private Instance Methods

change_url_options() { || ... } click to toggle source
# File lib/cell/url_options.rb, line 13
def change_url_options(&block)
  saved = Rails.application.routes.default_url_options[:host]
  Rails.application.routes.default_url_options[:host] = cell_host

  if block_given?
    begin
      yield
    ensure
      Rails.application.routes.default_url_options[:host] = saved
    end
  end
end