Module: Subdomainitis
- Defined in:
- lib/subdomainitis.rb,
lib/subdomainitis/spec_helpers.rb
Defined Under Namespace
Modules: RouteSetMethods, SpecHelpers
Classes: HostRequired, IsMaindomain, IsSubdomain, MainDomainRouteSet, RouteSetMiddleware, SubdomainRouteSet
Constant Summary
collapse
- SUBDOMAIN_KEY =
"_subdomain"
- DEFAULT_TLD_LENGTH =
1
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.extended(mapper) ⇒ Object
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
# File 'lib/subdomainitis.rb', line 197
def self.extended(mapper)
set = mapper.instance_variable_get(:@set)
unless set.is_a? RouteSetMethods
set.class_eval do
include RouteSetMethods
alias_method_chain :url_for, :subdomains
attr_accessor :subdomain_routes, :maindomain_routes, :use_fake_subdomains, :tld_length
end
end
delegate :tld_length=, :to => :@set
set.subdomainitis_defaults!
end
|
.monkeypatch_route_inspector! ⇒ Object
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
# File 'lib/subdomainitis.rb', line 221
def monkeypatch_route_inspector!
require 'rails/application/route_inspector'
name = :discover_rack_app
if defined? Rails::Application::RouteInspector
if Rails::Application::RouteInspector.instance_methods.include? name
old_discover_rack_app = Rails::Application::RouteInspector.instance_method name
Rails::Application::RouteInspector.instance_eval do
define_method name do |app|
old_discover_rack_app.bind(self).call(app) unless app.is_a? RouteSetMiddleware
end
end
end
end
end
|
Instance Method Details
#main_domain(&block) ⇒ Object
80
81
82
83
|
# File 'lib/subdomainitis.rb', line 80
def main_domain(&block)
maindomain_routeset = MainDomainRouteSet.new @set
maindomain_routeset.draw &block
end
|
#subdomain_as(subdomain_key, &block) ⇒ Object
75
76
77
78
|
# File 'lib/subdomainitis.rb', line 75
def subdomain_as(subdomain_key, &block)
subdomain_routeset = SubdomainRouteSet.new @set, subdomain_key
subdomain_routeset.draw &block
end
|
#use_fake_subdomains! ⇒ Object
85
86
87
|
# File 'lib/subdomainitis.rb', line 85
def use_fake_subdomains!
@set.use_fake_subdomains = true
end
|