class Fog::VcloudDirector::Compute::Collection

Public Instance Methods

_item_list() click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 347
def _item_list
  @items || item_list || []
end
all(lazy_load=true) click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 312
def all(lazy_load=true)
  lazy_load ? index : get_everyone
end
get(item_id) click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 316
def get(item_id)
  item = get_by_id(item_id)
  return nil unless item
  new(item)
end
get_by_name(item_name) click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 322
def get_by_name(item_name)
  item_found = _item_list.find { |item| item[:name] == item_name }
  return nil unless item_found
  get(item_found[:id])
end
get_everyone() click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 332
def get_everyone
  items = _item_list.map { |item| get_by_id(item[:id]) }
  load(items)
end
index() click to toggle source
# File lib/fog/vcloud_director/compute.rb, line 328
def index
  load(_item_list)
end
with_item_list(hashes) click to toggle source

Use pre-fetched list of items. Particularly useful when parent's XML already contains enough information about child entities, hence we can parse them on parent already to reduce API requests. Some examples:

- vApp XML contains all the information about each of its child VMs, so we can pre-fetch `vapp.vms`
- VM XML contains all the information about customization, so we can pre-fecth `vm.guest_customization`
- VM XML contains all the information about disks, so we can pre-fetch `vm.disks`
# File lib/fog/vcloud_director/compute.rb, line 342
def with_item_list(hashes)
  @items = Array(hashes)
  self
end