Module: SubdomainRoutes::Routing::Route

Defined in:
lib/subdomain_routes/routes.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) included(base)



45
46
47
# File 'lib/subdomain_routes/routes.rb', line 45

def self.included(base)
  [ :recognition_conditions, :generation_extraction, :segment_keys, :significant_keys, :recognition_extraction ].each { |method| base.alias_method_chain method, :subdomains }
end

Instance Method Details

- (Object) generation_extraction_with_subdomains



60
61
62
63
64
65
66
# File 'lib/subdomain_routes/routes.rb', line 60

def generation_extraction_with_subdomains
  results = [ generation_extraction_without_subdomains ]
  if conditions[:subdomains].is_a?(Symbol)
    results << "return [nil,nil] unless hash.delete(#{conditions[:subdomains].inspect})"
  end
  results.compact * "\n"
end

- (Object) recognition_conditions_with_subdomains



49
50
51
52
53
54
55
56
57
58
# File 'lib/subdomain_routes/routes.rb', line 49

def recognition_conditions_with_subdomains
  returning recognition_conditions_without_subdomains do |result|
    case conditions[:subdomains]
    when Array
      result << "conditions[:subdomains].include?(env[:subdomain])"
    when Symbol
      result << "(subdomain = env[:subdomain] unless env[:subdomain].blank?)"
    end
  end
end

- (Object) recognition_extraction_with_subdomains



83
84
85
86
87
# File 'lib/subdomain_routes/routes.rb', line 83

def recognition_extraction_with_subdomains
  returning recognition_extraction_without_subdomains do |result|
    result.unshift "\nparams[#{conditions[:subdomains].inspect}] = subdomain\n" if conditions[:subdomains].is_a? Symbol
  end
end

- (Object) reserved_subdomains



89
90
91
# File 'lib/subdomain_routes/routes.rb', line 89

def reserved_subdomains
  conditions[:subdomains].is_a?(Array) ? conditions[:subdomains] : []
end

- (Object) segment_keys_with_subdomains



68
69
70
71
72
# File 'lib/subdomain_routes/routes.rb', line 68

def segment_keys_with_subdomains
  returning segment_keys_without_subdomains do |result|
    result.unshift(conditions[:subdomains]) if conditions[:subdomains].is_a? Symbol
  end
end

- (Object) significant_keys_with_subdomains



74
75
76
77
78
79
80
81
# File 'lib/subdomain_routes/routes.rb', line 74

def significant_keys_with_subdomains
  returning significant_keys_without_subdomains do |result|
    if conditions[:subdomains].is_a? Symbol
      result << conditions[:subdomains]
      result.uniq!
    end
  end
end