Class: VCAP::Services::Service
Instance Attribute Summary collapse
-
#acls ⇒ Object
readonly
Returns the value of attribute acls.
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#bindable ⇒ Object
readonly
Returns the value of attribute bindable.
-
#default_plan ⇒ Object
readonly
Returns the value of attribute default_plan.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#documentation_url ⇒ Object
readonly
Returns the value of attribute documentation_url.
-
#extra ⇒ Object
readonly
Returns the value of attribute extra.
-
#guid ⇒ Object
Returns the value of attribute guid.
-
#info_url ⇒ Object
readonly
Returns the value of attribute info_url.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#plan_options ⇒ Object
readonly
Returns the value of attribute plan_options.
-
#plans ⇒ Object
readonly
Returns the value of attribute plans.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#supported_versions ⇒ Object
readonly
Returns the value of attribute supported_versions.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#unique_id ⇒ Object
readonly
Returns the value of attribute unique_id.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#version_aliases ⇒ Object
readonly
Returns the value of attribute version_aliases.
Instance Method Summary collapse
- #create_change_set(service_in_ccdb) ⇒ Object
-
#initialize(attrs) ⇒ Service
constructor
A new instance of Service.
- #same_tuple?(other) ⇒ Boolean
- #to_hash ⇒ Object
Constructor Details
#initialize(attrs) ⇒ Service
Returns a new instance of Service.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/base/service.rb', line 11 def initialize(attrs) @unique_id = attrs.fetch('unique_id') @label = attrs['label'] @active = attrs['active'] @active = true if @active.nil? @tags = attrs['tags'] @plan_options = attrs['plan_options'] @acls = attrs['acls'] @timeout = attrs['timeout'] @default_plan = attrs['default_plan'] @supported_versions = attrs['supported_versions'] @version_aliases = attrs['version_aliases'] @extra = attrs.fetch('extra') @info_url = attrs['info_url'] @documentation_url = attrs['documentation_url'] @bindable = attrs.fetch('bindable', true) @guid = attrs['guid'] @description = attrs['description'] @provider = attrs.fetch('provider') @version = attrs.fetch('version') @url = attrs.fetch('url') @plans = Plan.plan_hash_as_plan_array(attrs.fetch('plans')) @tags = attrs['tags'] end |
Instance Attribute Details
#acls ⇒ Object (readonly)
Returns the value of attribute acls.
6 7 8 |
# File 'lib/base/service.rb', line 6 def acls @acls end |
#active ⇒ Object (readonly)
Returns the value of attribute active.
6 7 8 |
# File 'lib/base/service.rb', line 6 def active @active end |
#bindable ⇒ Object (readonly)
Returns the value of attribute bindable.
6 7 8 |
# File 'lib/base/service.rb', line 6 def bindable @bindable end |
#default_plan ⇒ Object (readonly)
Returns the value of attribute default_plan.
6 7 8 |
# File 'lib/base/service.rb', line 6 def default_plan @default_plan end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/base/service.rb', line 6 def description @description end |
#documentation_url ⇒ Object (readonly)
Returns the value of attribute documentation_url.
6 7 8 |
# File 'lib/base/service.rb', line 6 def documentation_url @documentation_url end |
#extra ⇒ Object (readonly)
Returns the value of attribute extra.
6 7 8 |
# File 'lib/base/service.rb', line 6 def extra @extra end |
#guid ⇒ Object
Returns the value of attribute guid.
9 10 11 |
# File 'lib/base/service.rb', line 9 def guid @guid end |
#info_url ⇒ Object (readonly)
Returns the value of attribute info_url.
6 7 8 |
# File 'lib/base/service.rb', line 6 def info_url @info_url end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
6 7 8 |
# File 'lib/base/service.rb', line 6 def label @label end |
#plan_options ⇒ Object (readonly)
Returns the value of attribute plan_options.
6 7 8 |
# File 'lib/base/service.rb', line 6 def @plan_options end |
#plans ⇒ Object (readonly)
Returns the value of attribute plans.
6 7 8 |
# File 'lib/base/service.rb', line 6 def plans @plans end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
6 7 8 |
# File 'lib/base/service.rb', line 6 def provider @provider end |
#supported_versions ⇒ Object (readonly)
Returns the value of attribute supported_versions.
6 7 8 |
# File 'lib/base/service.rb', line 6 def supported_versions @supported_versions end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
6 7 8 |
# File 'lib/base/service.rb', line 6 def @tags end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
6 7 8 |
# File 'lib/base/service.rb', line 6 def timeout @timeout end |
#unique_id ⇒ Object (readonly)
Returns the value of attribute unique_id.
6 7 8 |
# File 'lib/base/service.rb', line 6 def unique_id @unique_id end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/base/service.rb', line 6 def url @url end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'lib/base/service.rb', line 6 def version @version end |
#version_aliases ⇒ Object (readonly)
Returns the value of attribute version_aliases.
6 7 8 |
# File 'lib/base/service.rb', line 6 def version_aliases @version_aliases end |
Instance Method Details
#create_change_set(service_in_ccdb) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/base/service.rb', line 36 def create_change_set(service_in_ccdb) if service_in_ccdb service_guid = service_in_ccdb.guid plans_to_update = [] plans_to_add = [] self.plans.each do |catalog_plan| ccdb_plan = service_in_ccdb.plans.find { |ccp| catalog_plan.unique_id == ccp.unique_id } ccdb_plan = service_in_ccdb.plans.find { |ccp| catalog_plan.name.to_s == ccp.name.to_s } unless ccdb_plan if ccdb_plan catalog_plan.guid = ccdb_plan.guid plans_to_update << catalog_plan else plans_to_add << catalog_plan end end else service_guid = nil plans_to_add = self.plans plans_to_update = [] end ServicePlanChangeSet.new(self, service_guid, plans_to_add: plans_to_add, plans_to_update: plans_to_update, ) end |
#same_tuple?(other) ⇒ Boolean
85 86 87 88 89 90 91 |
# File 'lib/base/service.rb', line 85 def same_tuple?(other) [self.label, self.provider, self.version].each { |x| return false if x.nil? } (self.label == other.label && self.provider == other.provider && self.version == other.version) end |
#to_hash ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/base/service.rb', line 66 def to_hash { "description" => description, "provider" => provider, "version" => version, "url" => url, "documentation_url" => documentation_url, "plans" => Plan.plans_array_to_hash(plans), "unique_id" => unique_id, "label" => label, "active" => active, "acls" => acls, "timeout" => timeout, "extra" => extra, "bindable" => bindable, "tags" => } end |