Class: OpenShift::Group
- Defined in:
- lib/openshift-origin-common/models/group.rb
Instance Attribute Summary collapse
-
#component_ref_name_map ⇒ Object
Returns the value of attribute component_ref_name_map.
-
#generated ⇒ Object
Returns the value of attribute generated.
-
#name ⇒ Object
Returns the value of attribute name.
-
#scaling ⇒ Object
Returns the value of attribute scaling.
Instance Method Summary collapse
- #add_component_ref(component_ref) ⇒ Object
- #component_refs(name = nil) ⇒ Object
- #component_refs=(data) ⇒ Object
- #from_descriptor(spec_hash = {}) ⇒ Object
- #get_name_prefix ⇒ Object
-
#initialize(name = "default") ⇒ Group
constructor
A new instance of Group.
- #to_descriptor ⇒ Object
Methods inherited from Model
attr_accessor, attr_reader, attr_writer, #attributes, #attributes=, #deleted?, exclude_attributes, excludes_attributes, gen_uuid, include_attributes, includes_attributes, #new_record?, #persisted?, primary_key, require_update_attributes, requires_update_attributes, #reset_state, #to_xml
Constructor Details
Instance Attribute Details
#component_ref_name_map ⇒ Object
Returns the value of attribute component_ref_name_map.
3 4 5 |
# File 'lib/openshift-origin-common/models/group.rb', line 3 def component_ref_name_map @component_ref_name_map end |
#generated ⇒ Object
Returns the value of attribute generated.
3 4 5 |
# File 'lib/openshift-origin-common/models/group.rb', line 3 def generated @generated end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/openshift-origin-common/models/group.rb', line 3 def name @name end |
#scaling ⇒ Object
Returns the value of attribute scaling.
3 4 5 |
# File 'lib/openshift-origin-common/models/group.rb', line 3 def scaling @scaling end |
Instance Method Details
#add_component_ref(component_ref) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/openshift-origin-common/models/group.rb', line 28 def add_component_ref(component_ref) component_ref_name_map_will_change! component_refs_will_change! @component_ref_name_map = {} if @component_ref_name_map.nil? if component_ref.class == ComponentRef @component_ref_name_map[component_ref.name] = component_ref else key = component_ref["name"] @component_ref_name_map[key] = ComponentRef.new @component_ref_name_map[key].attributes=component_ref end end |
#component_refs(name = nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/openshift-origin-common/models/group.rb', line 19 def component_refs(name=nil) @component_ref_name_map = {} if @component_ref_name_map.nil? if name.nil? @component_ref_name_map.values else @component_ref_name_map[name] end end |
#component_refs=(data) ⇒ Object
13 14 15 16 17 |
# File 'lib/openshift-origin-common/models/group.rb', line 13 def component_refs=(data) data.each do |value| add_component_ref(value) end end |
#from_descriptor(spec_hash = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/openshift-origin-common/models/group.rb', line 51 def from_descriptor(spec_hash = {}) self.name = spec_hash["Name"] || "default" if spec_hash.has_key?("Components") spec_hash["Components"].each do |n,c| self.add_component_ref(ComponentRef.new(n).from_descriptor(c)) end end self.scaling.from_descriptor spec_hash["Scaling"] if spec_hash.has_key?("Scaling") self end |
#get_name_prefix ⇒ Object
74 75 76 77 |
# File 'lib/openshift-origin-common/models/group.rb', line 74 def get_name_prefix return "" if self.generated return "/group-" + self.name end |
#to_descriptor ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/openshift-origin-common/models/group.rb', line 62 def to_descriptor components = {} self.component_refs.each do |c| components[c.name] = c.to_descriptor end { "Components" => components, "Scaling" => self.scaling.to_descriptor } end |