Class: SiteFramework::Routing::DefaultConstraint

Inherits:
Object
  • Object
show all
Defined in:
lib/site_framework/routing/default_constraint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#loggerObject (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

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/site_framework/routing/default_constraint.rb', line 12

def matches?(request)
  @domain_name = request.host

  if @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