Class: Ppl::Service::PhoneNumber
- Inherits:
-
Object
- Object
- Ppl::Service::PhoneNumber
- Defined in:
- lib/ppl/service/phone_number.rb
Instance Attribute Summary collapse
-
#storage ⇒ Object
writeonly
Sets the attribute storage.
Instance Method Summary collapse
- #add(contact, number, options) ⇒ Object
- #remove(contact, number) ⇒ Object
- #update(contact, number, options) ⇒ Object
Instance Attribute Details
#storage=(value) ⇒ Object (writeonly)
Sets the attribute storage
3 4 5 |
# File 'lib/ppl/service/phone_number.rb', line 3 def storage=(value) @storage = value end |
Instance Method Details
#add(contact, number, options) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/ppl/service/phone_number.rb', line 5 def add(contact, number, ) phone_number = Ppl::Entity::PhoneNumber.new(number) contact.phone_numbers << phone_number update_phone_number(contact, phone_number, ) @storage.save_contact(contact) end |
#remove(contact, number) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/ppl/service/phone_number.rb', line 18 def remove(contact, number) contact.phone_numbers.select! do |phone_number| phone_number.number != number end @storage.save_contact(contact) end |
#update(contact, number, options) ⇒ Object
12 13 14 15 16 |
# File 'lib/ppl/service/phone_number.rb', line 12 def update(contact, number, ) matching_numbers = contact.phone_numbers.select { |p| p.number == number } matching_numbers.each { |mn| update_phone_number(contact, mn, ) } @storage.save_contact(contact) end |