Class: CIMI::Model::Base
- Extended by:
- CollectionMethods, Deltacloud::Helpers::Database
- Includes:
- Helpers::SelectBaseMethods
- Defined in:
- lib/cimi/models/base.rb
Direct Known Subclasses
Action, Address, AddressCreate, AddressTemplate, AddressTemplateCreate, CloudEntryPoint, Credential, CredentialCreate, CredentialTemplate, Disk, ForwardingGroup, ForwardingGroupTemplate, Machine, MachineConfiguration, MachineCreate, MachineImage, MachineImageCreate, MachineTemplate, MachineTemplateCreate, MachineVolume, Network, NetworkConfiguration, NetworkCreate, NetworkPort, NetworkPortConfiguration, NetworkPortTemplate, NetworkTemplate, ResourceMetadata, System, SystemTemplate, Volume, VolumeConfiguration, VolumeCreate, VolumeImage, VolumeImageCreate, VolumeTemplate, VolumeTemplateCreate
Constant Summary
Constants included from Deltacloud::Helpers::Database
Deltacloud::Helpers::Database::DATABASE_COLLECTIONS
Constants inherited from Resource
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
- #[]=(a, v) ⇒ Object
-
#destroy ⇒ Object
Destroy the database attributes for this model.
-
#extract_properties!(data) ⇒ Object
FIXME: Kludge around the fact that we do not have proper *Create objects that deserialize properties by themselves.
-
#initialize(values = {}) ⇒ Base
constructor
A new instance of Base.
- #ref_id(ref_url) ⇒ Object
-
#save ⇒ Object
Save the common attributes name, description, and properties to the database.
Methods included from Deltacloud::Helpers::Database
current_db, current_provider, provides?
Methods included from Deltacloud::Helpers::Drivers
#driver, #driver_class, #driver_class_name, #driver_name, #driver_source_name, #driver_symbol, included, #provider_name
Methods included from CollectionMethods
acts_as_root_entity, all, collection_class, collection_class=, list
Methods included from Helpers::SelectBaseMethods
Methods inherited from Resource
#[], add_attributes!, all_uri, #base_id, base_schema, base_schema_cloned?, clone_base_schema, from_json, from_xml, inherited, parse, #prepare, required_attributes, resource_uri, to_json, #to_json, to_xml, #to_xml, #validate!, xml_tag_name
Methods included from Schema::DSL
#array, #collection, #hash, #href, #ref, #resource_attr, #scalar, #struct, #text
Methods included from Helpers::FilterResourceMethods
#filter_by, #parse_filter_opts
Methods included from Helpers::SelectResourceMethods
#select_by, #select_by_arr_index, #select_by_arr_range
Constructor Details
#initialize(values = {}) ⇒ Base
Returns a new instance of Base.
126 127 128 129 |
# File 'lib/cimi/models/base.rb', line 126 def initialize(values = {}) super(values) retrieve_entity end |
Instance Method Details
#[]=(a, v) ⇒ Object
131 132 133 134 135 |
# File 'lib/cimi/models/base.rb', line 131 def []=(a, v) v = super retrieve_entity if a == :id v end |
#destroy ⇒ Object
Destroy the database attributes for this model
150 151 152 153 |
# File 'lib/cimi/models/base.rb', line 150 def destroy @entity.destroy self end |
#extract_properties!(data) ⇒ Object
FIXME: Kludge around the fact that we do not have proper *Create objects that deserialize properties by themselves
157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/cimi/models/base.rb', line 157 def extract_properties!(data) h = {} if data['property'] # Data came from XML h = data['property'].inject({}) do |r,v| r[v['key']] = v['content'] r end elsif data['properties'] h = data['properties'] end property ||= {} property.merge!(h) end |
#ref_id(ref_url) ⇒ Object
172 173 174 |
# File 'lib/cimi/models/base.rb', line 172 def ref_id(ref_url) ref_url.split('/').last if ref_url end |
#save ⇒ Object
Save the common attributes name, description, and properties to the database
139 140 141 142 143 144 145 146 147 |
# File 'lib/cimi/models/base.rb', line 139 def save if @entity @entity.name = name @entity.description = description @entity.properties = property @entity.save end self end |