Class: Hula::ServiceBroker::Service
- Inherits:
-
Object
- Object
- Hula::ServiceBroker::Service
- Defined in:
- lib/hula/service_broker/service.rb
Instance Attribute Summary collapse
-
#bindable ⇒ Object
readonly
Returns the value of attribute bindable.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#plans ⇒ Object
readonly
Returns the value of attribute plans.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(args = {}) ⇒ Service
constructor
A new instance of Service.
- #plan(plan_name) ⇒ Object
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
#bindable ⇒ Object (readonly)
Returns the value of attribute bindable.
25 26 27 |
# File 'lib/hula/service_broker/service.rb', line 25 def bindable @bindable end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
25 26 27 |
# File 'lib/hula/service_broker/service.rb', line 25 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
25 26 27 |
# File 'lib/hula/service_broker/service.rb', line 25 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
25 26 27 |
# File 'lib/hula/service_broker/service.rb', line 25 def name @name end |
#plans ⇒ Object (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 |