Class: VCAP::Services::Plan
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#extra ⇒ Object
readonly
Returns the value of attribute extra.
-
#free ⇒ Object
readonly
Returns the value of attribute free.
-
#guid ⇒ Object
Returns the value of attribute guid.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#unique_id ⇒ Object
readonly
Returns the value of attribute unique_id.
Class Method Summary collapse
Instance Method Summary collapse
- #get_add_hash(service_guid) ⇒ Object
- #get_update_hash(service_guid) ⇒ Object
-
#initialize(options) ⇒ Plan
constructor
A new instance of Plan.
- #to_hash ⇒ Object
Constructor Details
#initialize(options) ⇒ Plan
Returns a new instance of Plan.
6 7 8 9 10 11 12 13 14 |
# File 'lib/base/plan.rb', line 6 def initialize() @unique_id = .fetch(:unique_id) @guid = [:guid] @name = [:name] @description = [:description] @free = [:free] @extra = [:extra] @public = .fetch(:public, true) end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/base/plan.rb', line 3 def description @description end |
#extra ⇒ Object (readonly)
Returns the value of attribute extra.
3 4 5 |
# File 'lib/base/plan.rb', line 3 def extra @extra end |
#free ⇒ Object (readonly)
Returns the value of attribute free.
3 4 5 |
# File 'lib/base/plan.rb', line 3 def free @free end |
#guid ⇒ Object
Returns the value of attribute guid.
3 4 5 |
# File 'lib/base/plan.rb', line 3 def guid @guid end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/base/plan.rb', line 3 def name @name end |
#unique_id ⇒ Object (readonly)
Returns the value of attribute unique_id.
3 4 5 |
# File 'lib/base/plan.rb', line 3 def unique_id @unique_id end |
Class Method Details
.plan_hash_as_plan_array(plans) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/base/plan.rb', line 41 def self.plan_hash_as_plan_array(plans) plan_array = [] return plan_array unless plans if plans.first.is_a?(Plan) return plans else plans.each do |_, v| plan_array << Plan.new(v) end end plan_array end |
.plans_array_to_hash(plans_array) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/base/plan.rb', line 54 def self.plans_array_to_hash(plans_array) return [] unless plans_array plans_array_hash = [] plans_array.each do |plan| plans_array_hash << plan.to_hash end plans_array_hash end |
Instance Method Details
#get_add_hash(service_guid) ⇒ Object
35 36 37 38 39 |
# File 'lib/base/plan.rb', line 35 def get_add_hash(service_guid) plan_as_hash = self.to_hash plan_as_hash['service_guid'] = service_guid return plan_as_hash end |
#get_update_hash(service_guid) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/base/plan.rb', line 27 def get_update_hash(service_guid) plan_as_hash = self.to_hash plan_as_hash['service_guid'] = service_guid plan_as_hash.delete('unique_id') plan_as_hash.delete('public') return plan_as_hash end |
#to_hash ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/base/plan.rb', line 16 def to_hash { 'unique_id' => @unique_id, 'name' => @name, 'description' => @description, 'free' => @free, 'extra' => @extra, 'public' => @public, } end |