Class: Service::Proxy::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/service/proxy/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Config

Returns a new instance of Config.



6
7
8
# File 'lib/service/proxy/config.rb', line 6

def initialize(config = {})
  @config = config || {}
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



4
5
6
# File 'lib/service/proxy/config.rb', line 4

def config
  @config
end

Instance Method Details

#proxied_paths_matcherObject



10
11
12
# File 'lib/service/proxy/config.rb', line 10

def proxied_paths_matcher
  @proxied_paths_matcher ||= Regexp.union(services.collect(&:path_regexp))
end

#service_matching_path(path) ⇒ Object



14
15
16
# File 'lib/service/proxy/config.rb', line 14

def service_matching_path(path)
  services.detect { |service| service.path_regexp =~ path }
end

#servicesObject



18
19
20
# File 'lib/service/proxy/config.rb', line 18

def services
  @services ||= config.fetch(:services, {}).map { |k, v| ServiceConfig.new(k, v)  }
end