Class: Service::Proxy::Config
- Inherits:
-
Object
- Object
- Service::Proxy::Config
- Defined in:
- lib/service/proxy/config.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ Config
constructor
A new instance of Config.
- #proxied_paths_matcher ⇒ Object
- #service_matching_path(path) ⇒ Object
- #services ⇒ Object
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
#config ⇒ Object (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_matcher ⇒ Object
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 |
#services ⇒ Object
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 |