class SiteFramework::Routing::DefaultConstraint

Attributes

logger[R]

Public Class Methods

new(mapper, defaults = nil) click to toggle source
# 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

Public Instance Methods

matches?(request) click to toggle source
# 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

Private Instance Methods

domain() click to toggle source
# File lib/site_framework/routing/default_constraint.rb, line 44
def domain
end
domain_name() click to toggle source
# File lib/site_framework/routing/default_constraint.rb, line 47
def domain_name
end
patch_request(request) click to toggle source
# File lib/site_framework/routing/default_constraint.rb, line 35
def patch_request(request)
  SiteFramework::CurrentState.instance.domain_name = nil
  SiteFramework::CurrentState.instance.domain      = nil
  SiteFramework::CurrentState.instance.site        = nil

  request.instance_eval do
    def site
    end

    def domain
    end

    def domain_name
    end

  end
end
site() click to toggle source
# File lib/site_framework/routing/default_constraint.rb, line 41
def site
end