Class: Shared::Collection Abstract

Inherits:
Resource show all
Defined in:
lib/vas/shared/collection.rb

Overview

This class is abstract.

A dynamic collection of items

Instance Attribute Summary

Attributes inherited from Resource

#location, #security

Instance Method Summary collapse

Constructor Details

#initialize(location, client, type, entry_class) ⇒ Collection

Returns a new instance of Collection.



29
30
31
32
33
# File 'lib/vas/shared/collection.rb', line 29

def initialize(location, client, type, entry_class)
  super(location, client)
  @type = type
  @entry_class = entry_class
end

Instance Method Details

#each {|item| ... } ⇒ void

This method returns an undefined value.

Gets the items in the collection from the server. Calls the block once for each item.

Yield Parameters:

  • item

    an item in the collection



40
41
42
43
44
45
46
47
48
# File 'lib/vas/shared/collection.rb', line 40

def each
  items = client.get(location)[@type]

  if (!items.nil?)
    client.get(location)[@type].each { |item|
      yield entry_class.new(Util::LinkUtils.get_self_link_href(item), client)
    }
  end
end