Class: Hula::ServiceBroker::Service

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Service

Returns a new instance of Service.



17
18
19
20
21
22
23
# File 'lib/hula/service_broker/service.rb', line 17

def initialize(args = {})
  @id          = args.fetch(:id)
  @name        = args.fetch(:name)
  @description = args.fetch(:description)
  @bindable    = !!args.fetch(:bindable)
  @plans       = args.fetch(:plans).map { |p| Plan.new(p.merge(service_id: self.id)) }
end

Instance Attribute Details

#bindableObject (readonly)

Returns the value of attribute bindable.



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

def bindable
  @bindable
end

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#plansObject (readonly)

Returns the value of attribute plans.



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

def plans
  @plans
end

Instance Method Details

#==(other) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/hula/service_broker/service.rb', line 27

def ==(other)
  is_a?(other.class) &&
    id == other.id &&
    name == other.name &&
    description == other.description &&
    bindable == other.bindable &&
    plans == other.plans
end

#plan(plan_name) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/hula/service_broker/service.rb', line 36

def plan(plan_name)
  plans.find { |p| p.name == plan_name } or
    fail(PlanNotFoundError, [
      %{Unknown plan with name: #{plan_name.inspect}},
      "  Known plan names are: #{plans.map(&:name).inspect}"
      ].join("\n")
    )
end