Class: Axel::Configurators::Services

Inherits:
Object
  • Object
show all
Defined in:
lib/axel/configurators/services.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeServices

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

#servicesObject (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, options = {})
  service = add_service service_name, (options.delete(:service) || {})[:url]
  service.add_resource resource_name, options
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

#resourcesObject



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