Class: Hula::ServiceBroker::Catalog

Inherits:
Object
  • Object
show all
Defined in:
lib/hula/service_broker/catalog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Catalog

Returns a new instance of Catalog.



20
21
22
# File 'lib/hula/service_broker/catalog.rb', line 20

def initialize(args = {})
  @services = args.fetch(:services).map { |s| Service.new(s) }
end

Instance Attribute Details

#servicesObject (readonly)

Returns the value of attribute services.



18
19
20
# File 'lib/hula/service_broker/catalog.rb', line 18

def services
  @services
end

Instance Method Details

#==(other) ⇒ Object



24
25
26
27
# File 'lib/hula/service_broker/catalog.rb', line 24

def ==(other)
  is_a?(other.class) &&
    services == other.services
end

#service(service_name) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/hula/service_broker/catalog.rb', line 29

def service(service_name)
  services.find { |s| s.name == service_name } or
    fail(ServiceNotFoundError, [
      %{Unknown service with name: #{service_name.inspect}},
      "  Known service names: #{services.map(&:name).inspect}"
      ].join("\n")
    )
end

#service_plan(service_name, plan_name) ⇒ Object



38
39
40
# File 'lib/hula/service_broker/catalog.rb', line 38

def service_plan(service_name, plan_name)
  service(service_name).plan(plan_name)
end