Class: Deltacloud::BaseModel

Inherits:
Object
  • Object
show all
Defined in:
lib/deltacloud/models/base_model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(init = nil) ⇒ BaseModel

Returns a new instance of BaseModel.



22
23
24
25
26
27
28
29
# File 'lib/deltacloud/models/base_model.rb', line 22

def initialize(init=nil)
  if ( init )
    @id=init[:id]
    init.each{|k,v|
      self.send( "#{k}=", v ) if ( self.respond_to?( "#{k}=" ) )
    }
  end
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



20
21
22
# File 'lib/deltacloud/models/base_model.rb', line 20

def description
  @description
end

#nameObject

Returns the value of attribute name.



20
21
22
# File 'lib/deltacloud/models/base_model.rb', line 20

def name
  @name
end

Class Method Details

.attr_accessor(*vars) ⇒ Object



31
32
33
34
35
# File 'lib/deltacloud/models/base_model.rb', line 31

def self.attr_accessor(*vars)
  @attributes ||= [:id]
  @attributes.concat vars
  super
end

.attributesObject



37
38
39
# File 'lib/deltacloud/models/base_model.rb', line 37

def self.attributes
  @attributes
end

Instance Method Details

#attributesObject



41
42
43
# File 'lib/deltacloud/models/base_model.rb', line 41

def attributes
  self.class.attributes
end

#idObject



45
46
47
# File 'lib/deltacloud/models/base_model.rb', line 45

def id
  @id
end

#to_entityObject



49
50
51
# File 'lib/deltacloud/models/base_model.rb', line 49

def to_entity
  self.class.name.downcase
end