Class: Oneview::Entity::Contact

Inherits:
Object
  • Object
show all
Defined in:
lib/oneview/entity/contact.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContact

Returns a new instance of Contact.



6
7
8
9
# File 'lib/oneview/entity/contact.rb', line 6

def initialize
  self.phone = Phone.new
  self.dynamic_fields = Array.new
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



4
5
6
# File 'lib/oneview/entity/contact.rb', line 4

def address
  @address
end

#birthdayObject

Returns the value of attribute birthday.



4
5
6
# File 'lib/oneview/entity/contact.rb', line 4

def birthday
  @birthday
end

#cityObject

Returns the value of attribute city.



4
5
6
# File 'lib/oneview/entity/contact.rb', line 4

def city
  @city
end

#dynamic_fieldsObject

Returns the value of attribute dynamic_fields.



4
5
6
# File 'lib/oneview/entity/contact.rb', line 4

def dynamic_fields
  @dynamic_fields
end

#emailObject

Returns the value of attribute email.



4
5
6
# File 'lib/oneview/entity/contact.rb', line 4

def email
  @email
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/oneview/entity/contact.rb', line 4

def id
  @id
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/oneview/entity/contact.rb', line 4

def name
  @name
end

#phoneObject

Returns the value of attribute phone.



4
5
6
# File 'lib/oneview/entity/contact.rb', line 4

def phone
  @phone
end

#stateObject

Returns the value of attribute state.



4
5
6
# File 'lib/oneview/entity/contact.rb', line 4

def state
  @state
end

#zip_codeObject

Returns the value of attribute zip_code.



4
5
6
# File 'lib/oneview/entity/contact.rb', line 4

def zip_code
  @zip_code
end

Instance Method Details

#as_parameterObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/oneview/entity/contact.rb', line 11

def as_parameter
  variables = instance_variables.map do |name|
    case name
      when :@phone
        ["phone_attributes", instance_variable_get(name).as_parameter]
      when :@dynamic_fields
      else 
        [name.to_s.tr("@", ""), instance_variable_get(name)]
    end
  end
  
  self.dynamic_fields.each do |dynamic_field|
    variables << [dynamic_field.name, dynamic_field.value]
  end
  
  Hash[variables.compact]
end