Class: Amorail::Property::PropertyItem

Inherits:
Object
  • Object
show all
Includes:
MethodMissing
Defined in:
lib/amorail/property.rb

Direct Known Subclasses

Company, Contact, Lead, Task

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MethodMissing

#method_missing, #respond_to_missing?

Constructor Details

#initialize(data) ⇒ PropertyItem

Returns a new instance of PropertyItem.



40
41
42
# File 'lib/amorail/property.rb', line 40

def initialize(data)
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Amorail::MethodMissing

Class Attribute Details

.source_nameObject

Returns the value of attribute source_name.



24
25
26
# File 'lib/amorail/property.rb', line 24

def source_name
  @source_name
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



38
39
40
# File 'lib/amorail/property.rb', line 38

def data
  @data
end

Class Method Details

.parse(data) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/amorail/property.rb', line 26

def parse(data)
  hash = {}
  data['custom_fields'].fetch(source_name, []).each do |contact|
    identifier = contact['code'].presence || contact['name'].presence
    next if identifier.nil?

    hash[identifier.downcase] = PropertyItem.new(contact)
  end
  new hash
end

Instance Method Details

#[](key) ⇒ Object



44
45
46
# File 'lib/amorail/property.rb', line 44

def [](key)
  @data[key]
end