Class: VagrantPlugins::Cloudstack::Model::CloudstackResource

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-cloudstack/model/cloudstack_resource.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name, kind) ⇒ CloudstackResource

Returns a new instance of CloudstackResource.



8
9
10
11
12
13
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 8

def initialize(id, name, kind)
  raise 'Resource must have a kind' if kind.nil? || kind.empty?
  @id             = id
  @name           = name
  @kind           = kind
end

Instance Attribute Details

#detailsObject

Returns the value of attribute details.



5
6
7
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 5

def details
  @details
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 5

def id
  @id
end

#kindObject (readonly)

Returns the value of attribute kind.



6
7
8
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 6

def kind
  @kind
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 5

def name
  @name
end

Class Method Details

.create_id_list(ids, kind) ⇒ Object



37
38
39
40
41
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 37

def self.create_id_list(ids, kind)
  ids.each_with_object([]) do |id, resources|
    resources << CloudstackResource.new(id, nil, kind)
  end
end

.create_list(ids, names, kind) ⇒ Object



31
32
33
34
35
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 31

def self.create_list(ids, names, kind)
  return create_id_list(ids, kind)     unless ids.empty?
  return create_name_list(names, kind) unless names.empty?
  []
end

.create_name_list(names, kind) ⇒ Object



43
44
45
46
47
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 43

def self.create_name_list(names, kind)
  names.each_with_object([]) do |name, resources|
    resources << CloudstackResource.new(nil, name, kind)
  end
end

Instance Method Details

#is_id_undefined?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 19

def is_id_undefined?
  id.nil? || id.empty?
end

#is_name_undefined?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 23

def is_name_undefined?
  name.nil? || name.empty?
end

#is_undefined?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 15

def is_undefined?
  is_id_undefined? and is_name_undefined?
end

#to_sObject



27
28
29
# File 'lib/vagrant-cloudstack/model/cloudstack_resource.rb', line 27

def to_s
  "#{kind} - #{id || '<unknown id>'}:#{name || '<unknown name>'}"
end