Module: Pupa::Concerns::Contactable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Membership, Organization, Person, Post
- Defined in:
- lib/pupa/models/concerns/contactable.rb
Overview
Adds the Popolo contact_details
property to a model.
Instance Method Summary collapse
-
#add_contact_detail(type, value, note: nil, label: nil, valid_from: nil, valid_until: nil) ⇒ Object
Adds a contact detail.
-
#contact_details=(contact_details) ⇒ Object
Sets the contact details.
- #initialize(*args) ⇒ Object
Instance Method Details
#add_contact_detail(type, value, note: nil, label: nil, valid_from: nil, valid_until: nil) ⇒ Object
Adds a contact detail.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pupa/models/concerns/contactable.rb', line 32 def add_contact_detail(type, value, note: nil, label: nil, valid_from: nil, valid_until: nil) data = {type: type, value: value} if note data[:note] = note end if label data[:label] = label end if valid_from data[:valid_from] = valid_from end if valid_until data[:valid_until] = valid_until end if type.present? && value.present? @contact_details << data end end |
#contact_details=(contact_details) ⇒ Object
Sets the contact details.
20 21 22 |
# File 'lib/pupa/models/concerns/contactable.rb', line 20 def contact_details=(contact_details) @contact_details = ContactDetailList.new(symbolize_keys(contact_details)) end |
#initialize(*args) ⇒ Object
12 13 14 15 |
# File 'lib/pupa/models/concerns/contactable.rb', line 12 def initialize(*args) @contact_details = ContactDetailList.new super end |