Class: Axel::Configurators::Services
- Inherits:
-
Object
- Object
- Axel::Configurators::Services
- Defined in:
- lib/axel/configurators/services.rb
Instance Attribute Summary collapse
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Instance Method Summary collapse
- #add_resource(service_name, resource_name, options = {}) ⇒ Object
- #add_service(service_name, url) ⇒ Object
-
#initialize ⇒ Services
constructor
A new instance of Services.
- #resources ⇒ Object
Constructor Details
#initialize ⇒ Services
Returns a new instance of Services.
6 7 8 |
# File 'lib/axel/configurators/services.rb', line 6 def initialize @services = {}.with_indifferent_access end |
Instance Attribute Details
#services ⇒ Object (readonly)
Returns the value of attribute services.
5 6 7 |
# File 'lib/axel/configurators/services.rb', line 5 def services @services end |
Instance Method Details
#add_resource(service_name, resource_name, options = {}) ⇒ Object
23 24 25 26 |
# File 'lib/axel/configurators/services.rb', line 23 def add_resource(service_name, resource_name, = {}) service = add_service service_name, (.delete(:service) || {})[:url] service.add_resource resource_name, end |
#add_service(service_name, url) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/axel/configurators/services.rb', line 14 def add_service(service_name, url) if services[service_name] services[service_name].url = url if url services[service_name] else services[service_name] = Configurations::Service.new(service_name, url) end end |
#resources ⇒ Object
10 11 12 |
# File 'lib/axel/configurators/services.rb', line 10 def resources services.values.collect(&:resources).inject({}.with_indifferent_access) { |hash, pair| hash.merge pair } end |