Module: CIMI::Model::CollectionMethods

Included in:
Base
Defined in:
lib/cimi/models/collection.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_root_entity(opts = {}) ⇒ Object



117
118
119
120
# File 'lib/cimi/models/collection.rb', line 117

def acts_as_root_entity(opts = {})
  self.collection_class = Collection.generate(self)
  CIMI::Model.register_as_root_entity! self, opts
end

#collection_classObject



113
114
115
# File 'lib/cimi/models/collection.rb', line 113

def collection_class
  @collection_class
end

#collection_class=(klass) ⇒ Object



109
110
111
# File 'lib/cimi/models/collection.rb', line 109

def collection_class=(klass)
  @collection_class = klass
end

#list(id, entries, params = {}) ⇒ Object

Return a collection of entities



123
124
125
126
127
128
129
130
131
132
# File 'lib/cimi/models/collection.rb', line 123

def list(id, entries, params = {})
  params[:id] = id
  params[:entries] = entries
  params[:count] = params[:entries].size
  if params[:add_url]
    params[:operations] ||= []
    params[:operations] << { :rel => "add", :href => params.delete(:add_url) }
  end
  collection_class.new(params)
end