Class: CIMI::Model::ResourceMetadata

Inherits:
Base show all
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

#attribute_values

Class Method Summary collapse

Methods inherited from Base

acts_as_root_entity, all, #filter_attributes, list

Methods included from Deltacloud::Helpers::Database

#current_db, #current_provider, #delete_attributes_for, #extract_attribute_value, #get_entity, #load_attributes_for, #provides?, #store_attributes_for, #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 inherited from Resource

<<, #[], #[]=, add_attributes!, all_uri, base_schema, base_schema_cloned?, clone_base_schema, #filter_by, #filter_by_arr_index, #filter_by_arr_range, 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

Constructor Details

This class inherits a constructor from CIMI::Model::Resource

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|
      meta = (resource_class, context)
       << meta unless none_defined(meta)
    end
    return 
  else
    resource_class = CIMI::Model.const_get("#{id.camelize}")
    (resource_class, context)
  end
end

.resource_attributesObject



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