Class: Amorail::Property::PropertyItem
- Inherits:
-
Object
- Object
- Amorail::Property::PropertyItem
- Includes:
- MethodMissing
- Defined in:
- lib/amorail/property.rb
Class Attribute Summary collapse
-
.source_name ⇒ Object
Returns the value of attribute source_name.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(data) ⇒ PropertyItem
constructor
A new instance of PropertyItem.
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_name ⇒ Object
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
#data ⇒ Object (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 |