Class: SiteFramework::Routing::DefaultConstraint
- Inherits:
-
Object
- Object
- SiteFramework::Routing::DefaultConstraint
- Defined in:
- lib/site_framework/routing/default_constraint.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(mapper, defaults = nil) ⇒ DefaultConstraint
constructor
A new instance of DefaultConstraint.
- #matches?(request) ⇒ Boolean
Constructor Details
#initialize(mapper, defaults = nil) ⇒ DefaultConstraint
Returns a new instance of DefaultConstraint.
5 6 7 8 9 |
# File 'lib/site_framework/routing/default_constraint.rb', line 5 def initialize(mapper, defaults = nil) @logger = Rails.logger @mapper = mapper @default_domains = defaults || SiteFramework::Engine.default_domains end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/site_framework/routing/default_constraint.rb', line 3 def logger @logger end |
Instance Method Details
#matches?(request) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/site_framework/routing/default_constraint.rb', line 12 def matches?(request) return true if @matched return false if @matched == false @domain_name = request.host logger.debug("[DEFAULT] REQUEST HOST: #{request.host}") if @mathced = @default_domains.include?(@domain_name) logger.debug('Loading default site configuration') patch_request(request) true else logger.warn("Domain name '#{request.host}' does not match with any exist domains") patch_request(request) false end end |