class CIMI::Model::ResourceMetadata

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Public Class Methods

add_resource_attribute!(klass, name, opts={}) click to toggle source
# 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) click to toggle source
# File lib/cimi/models/resource_metadata.rb, line 54
def self.find(id, context)
  if id == :all
    resource_metadata = []
    CIMI::Model.root_entities.each do |resource_class|
      meta = resource_metadata_for(resource_class, context)
      resource_metadata << meta unless none_defined(meta)
    end
    return resource_metadata
  else
    resource_class = CIMI::Model.const_get("#{id.camelize}")
    resource_metadata_for(resource_class, context)
  end
end
resource_attributes() click to toggle source
# File lib/cimi/models/resource_metadata.rb, line 82
def self.resource_attributes
  @resource_attributes ||= {}
end
resource_metadata_for(resource_class, context) click to toggle source
# File lib/cimi/models/resource_metadata.rb, line 68
def self.resource_metadata_for(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.resource_metadata_url(cimi_resource.underscore),
            :name => cimi_resource,
            :type_uri => resource_class.resource_uri,
            :attributes => attributes,
            :capabilities => capabilities,
            :actions => actions
  })
end