Class: CIMI::Model::ResourceMetadata
- Defined in:
- lib/cimi/models/resource_metadata.rb
Constant Summary
Constants included from Deltacloud::Helpers::Database
Deltacloud::Helpers::Database::DATABASE_COLLECTIONS
Constants inherited from Resource
CIMI::Model::Resource::CMWG_NAMESPACE
Instance Attribute Summary
Attributes inherited from Resource
Class Method Summary collapse
- .add_resource_attribute!(klass, name, opts = {}) ⇒ Object
- .find(id, context) ⇒ Object
- .resource_attributes ⇒ Object
- .resource_metadata_for(resource_class, context) ⇒ Object
Methods inherited from Base
#[]=, #destroy, #extract_properties!, #initialize, #save
Methods included from Deltacloud::Helpers::Database
#current_db, #current_provider, #provides?, #test_environment?
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, #initialize, parse, #prepare, resource_uri, to_json, #to_json, to_xml, #to_xml, xml_tag_name
Methods included from Schema::DSL
#array, #collection, #hash, #href, #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
This class inherits a constructor from CIMI::Model::Base
Class Method Details
.add_resource_attribute!(klass, name, opts = {}) ⇒ Object
86 87 88 89 |
# File 'lib/cimi/models/resource_metadata.rb', line 86 def self.add_resource_attribute!(klass, name, opts={}) resource_attributes[klass.name] ||= {} resource_attributes[klass.name][name] = opts end |
.find(id, context) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/cimi/models/resource_metadata.rb', line 54 def self.find(id, context) if id == :all = [] CIMI::Model.root_entities.each do |resource_class| = (resource_class, context) << unless none_defined() end return else resource_class = CIMI::Model.const_get("#{id.camelize}") (resource_class, context) end end |
.resource_attributes ⇒ Object
82 83 84 |
# File 'lib/cimi/models/resource_metadata.rb', line 82 def self.resource_attributes @resource_attributes ||= {} end |
.resource_metadata_for(resource_class, context) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cimi/models/resource_metadata.rb', line 68 def self.(resource_class, context) attributes = rm_attributes_for(resource_class, context) capabilities = rm_capabilities_for(resource_class, context) actions = rm_actions_for(resource_class, context) cimi_resource = resource_class.name.split("::").last self.new({ :id => context.(cimi_resource.underscore), :name => cimi_resource, :type_uri => resource_class.resource_uri, :attributes => attributes, :capabilities => capabilities, :actions => actions }) end |