Class: VCloud::BaseVCloudEntity

Inherits:
Object
  • Object
show all
Includes:
RestApi
Defined in:
lib/vcloud/base_vcloud_entity.rb

Overview

Base class for all vCloud entities (Org, CatalogItem, vApp, etc.)

Direct Known Subclasses

Catalog, CatalogItem, Client, Org, OrgList, Task, VApp, Vdc

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RestApi

#build_generic_http_opts, #create, #delete, #http_request, #parse_response, #post, #refresh, #update

Constructor Details

#initialize(params = {}) ⇒ BaseVCloudEntity

Returns a new instance of BaseVCloudEntity.



12
13
14
15
16
17
# File 'lib/vcloud/base_vcloud_entity.rb', line 12

def initialize(params = {})
  initialize_args.each do |arg|
    self.instance_variable_set("@#{arg}".to_sym, params[arg])
  end
  @type = self.type
end

Class Method Details

.attr_accessor(*args) ⇒ Object



44
45
46
47
# File 'lib/vcloud/base_vcloud_entity.rb', line 44

def self.attr_accessor *args
  super *args
  args.each { |arg| self.class_variable_get(:@@initialize_args) << arg }
end

.attr_reader(*args) ⇒ Object



34
35
36
37
# File 'lib/vcloud/base_vcloud_entity.rb', line 34

def self.attr_reader *args
  super *args
  args.each { |arg| self.class_variable_get(:@@initialize_args) << arg }
end

.attr_writer(*args) ⇒ Object



39
40
41
42
# File 'lib/vcloud/base_vcloud_entity.rb', line 39

def self.attr_writer *args
  super *args
  args.each { |arg| self.class_variable_get(:@@initialize_args) << arg }
end

.from_reference(ref, session) ⇒ Object

Retrieve an entity from a VCloud::Reference

Parameters:



28
29
30
31
32
# File 'lib/vcloud/base_vcloud_entity.rb', line 28

def self.from_reference(ref, session)
  obj = new(:href => ref.href, :session => session)
  obj.refresh 
  obj
end

.inherited(base) ⇒ Object



6
7
8
9
10
# File 'lib/vcloud/base_vcloud_entity.rb', line 6

def self.inherited(base)
  base.class_variable_set(:@@initialize_args, Set.new)
  base.send(:include, ParsesXml)
  base.class_eval { attr_accessor :session }
end

.typeObject



19
20
21
# File 'lib/vcloud/base_vcloud_entity.rb', line 19

def self.type
  self.class_variable_get(:@@content_type)
end