Class: Rage::Router::Strategies::Host::HostStorage
- Inherits:
-
Object
- Object
- Rage::Router::Strategies::Host::HostStorage
- Defined in:
- lib/rage/router/strategies/host.rb
Instance Method Summary collapse
- #get(host) ⇒ Object
-
#initialize ⇒ HostStorage
constructor
A new instance of HostStorage.
- #set(host, value) ⇒ Object
Constructor Details
#initialize ⇒ HostStorage
Returns a new instance of HostStorage.
26 27 28 29 |
# File 'lib/rage/router/strategies/host.rb', line 26 def initialize @hosts = {} @regexp_hosts = [] end |
Instance Method Details
#get(host) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rage/router/strategies/host.rb', line 31 def get(host) exact = @hosts[host] return exact if exact @regexp_hosts.each do |regexp| return regexp[:value] if regexp[:host] =~ host.to_s end nil end |
#set(host, value) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/rage/router/strategies/host.rb', line 42 def set(host, value) if host.is_a?(Regexp) @regexp_hosts << { host: host, value: value } else @hosts[host] = value end end |