Class: Atethechon::ContactsSerializer
- Inherits:
-
Object
- Object
- Atethechon::ContactsSerializer
- Defined in:
- lib/atethechon/serializers/contacts_serializer.rb
Instance Attribute Summary collapse
-
#contacts ⇒ Object
readonly
Returns the value of attribute contacts.
-
#organization_identifier ⇒ Object
readonly
Returns the value of attribute organization_identifier.
Instance Method Summary collapse
-
#initialize(contacts:, organization_identifier:) ⇒ ContactsSerializer
constructor
A new instance of ContactsSerializer.
- #to_h ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
#initialize(contacts:, organization_identifier:) ⇒ ContactsSerializer
5 6 7 8 |
# File 'lib/atethechon/serializers/contacts_serializer.rb', line 5 def initialize(contacts:, organization_identifier:) @contacts = contacts @organization_identifier = organization_identifier end |
Instance Attribute Details
#contacts ⇒ Object (readonly)
Returns the value of attribute contacts.
3 4 5 |
# File 'lib/atethechon/serializers/contacts_serializer.rb', line 3 def contacts @contacts end |
#organization_identifier ⇒ Object (readonly)
Returns the value of attribute organization_identifier.
3 4 5 |
# File 'lib/atethechon/serializers/contacts_serializer.rb', line 3 def organization_identifier @organization_identifier end |
Instance Method Details
#to_h ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/atethechon/serializers/contacts_serializer.rb', line 14 def to_h { organization_identifier.to_s => { "contacts" => contacts.map { |c| c.to_h.transform_keys(&:to_s) } } } end |
#to_yaml ⇒ Object
10 11 12 |
# File 'lib/atethechon/serializers/contacts_serializer.rb', line 10 def to_yaml to_h.to_yaml end |