Module: SubdomainRoutes::Routing::Route
- Defined in:
- lib/subdomain_routes/routes.rb
Class Method Summary collapse
Instance Method Summary collapse
- #generation_extraction_with_subdomains ⇒ Object
- #recognition_conditions_with_subdomains ⇒ Object
- #recognition_extraction_with_subdomains ⇒ Object
- #reserved_subdomains ⇒ Object
- #segment_keys_with_subdomains ⇒ Object
- #significant_keys_with_subdomains ⇒ Object
Class Method Details
.included(base) ⇒ Object
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
#generation_extraction_with_subdomains ⇒ Object
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 |
#recognition_conditions_with_subdomains ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/subdomain_routes/routes.rb', line 49 def recognition_conditions_with_subdomains recognition_conditions_without_subdomains.tap 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 |
#recognition_extraction_with_subdomains ⇒ Object
83 84 85 86 87 |
# File 'lib/subdomain_routes/routes.rb', line 83 def recognition_extraction_with_subdomains recognition_extraction_without_subdomains.tap do |result| result.unshift "\nparams[#{conditions[:subdomains].inspect}] = subdomain\n" if conditions[:subdomains].is_a? Symbol end end |
#reserved_subdomains ⇒ Object
89 90 91 |
# File 'lib/subdomain_routes/routes.rb', line 89 def reserved_subdomains conditions[:subdomains].is_a?(Array) ? conditions[:subdomains] : [] end |
#segment_keys_with_subdomains ⇒ Object
68 69 70 71 72 |
# File 'lib/subdomain_routes/routes.rb', line 68 def segment_keys_with_subdomains segment_keys_without_subdomains.tap do |result| result.unshift(conditions[:subdomains]) if conditions[:subdomains].is_a? Symbol end end |
#significant_keys_with_subdomains ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/subdomain_routes/routes.rb', line 74 def significant_keys_with_subdomains significant_keys_without_subdomains.tap do |result| if conditions[:subdomains].is_a? Symbol result << conditions[:subdomains] result.uniq! end end end |