Class: Subdomainitis::SubdomainRouteSet
- Inherits:
-
ActionDispatch::Routing::RouteSet
- Object
- ActionDispatch::Routing::RouteSet
- Subdomainitis::SubdomainRouteSet
- Defined in:
- lib/subdomainitis.rb
Instance Attribute Summary collapse
-
#parent_route_set ⇒ Object
readonly
Returns the value of attribute parent_route_set.
-
#subdomain_key ⇒ Object
readonly
Returns the value of attribute subdomain_key.
Instance Method Summary collapse
- #add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true) ⇒ Object
-
#initialize(parent_route_set, subdomain_key) ⇒ SubdomainRouteSet
constructor
A new instance of SubdomainRouteSet.
- #wrap(app) ⇒ Object
Constructor Details
#initialize(parent_route_set, subdomain_key) ⇒ SubdomainRouteSet
Returns a new instance of SubdomainRouteSet.
31 32 33 34 |
# File 'lib/subdomainitis.rb', line 31 def initialize(parent_route_set, subdomain_key) @parent_route_set, @subdomain_key = parent_route_set, subdomain_key super *[] end |
Instance Attribute Details
#parent_route_set ⇒ Object (readonly)
Returns the value of attribute parent_route_set.
35 36 37 |
# File 'lib/subdomainitis.rb', line 35 def parent_route_set @parent_route_set end |
#subdomain_key ⇒ Object (readonly)
Returns the value of attribute subdomain_key.
35 36 37 |
# File 'lib/subdomainitis.rb', line 35 def subdomain_key @subdomain_key end |
Instance Method Details
#add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true) ⇒ Object
37 38 39 40 |
# File 'lib/subdomainitis.rb', line 37 def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true) parent_route_set.add_subdomain_route(name, subdomain_key) parent_route_set.add_route wrap(app), conditions, requirements, defaults, name, anchor end |
#wrap(app) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/subdomainitis.rb', line 42 def wrap(app) ActionDispatch::Routing::Mapper::Constraints.new( RouteSetMiddleware.new(parent_route_set, app, subdomain_key), [IsSubdomain.new(parent_route_set)], request_class ) end |