module Rack::Handler

Public Class Methods

default(options = {}) click to toggle source
# File lib/local-subdomain/rack/handler.rb, line 10
def self.default(options = {})
  orig_default.instance_eval do
    class << self
      alias_method :orig_run, :run
    end

    def self.run(app, options = {})
      env = (options[:environment] || Rails.env)
      if options[:Host] == 'localhost' && env == 'development'
        message(options[:Port])
        options.merge!(Host: '0.0.0.0')
      end
      orig_run(app, options)
    end

    def self.message(port)
      puts '****************************************************************************************'
      puts "* Override binding 'localhost' to '0.0.0.0' for http://lvh.me:#{port}/ support"
      puts '****************************************************************************************'
    end
  end
  orig_default
end
Also aliased as: orig_default
message(port) click to toggle source
# File lib/local-subdomain/rack/handler.rb, line 25
def self.message(port)
  puts '****************************************************************************************'
  puts "* Override binding 'localhost' to '0.0.0.0' for http://lvh.me:#{port}/ support"
  puts '****************************************************************************************'
end
orig_default(options = {})
Alias for: default
orig_run(app, options = {})
Alias for: run
run(app, options = {}) click to toggle source
# File lib/local-subdomain/rack/handler.rb, line 16
def self.run(app, options = {})
  env = (options[:environment] || Rails.env)
  if options[:Host] == 'localhost' && env == 'development'
    message(options[:Port])
    options.merge!(Host: '0.0.0.0')
  end
  orig_run(app, options)
end
Also aliased as: orig_run