Sha256: a3614ff01b7c21d123eacc7769c2020239dcea31e25fe6f5b0a933f158a88b9c
Contents?: true
Size: 1.03 KB
Versions: 13
Compression:
Stored size: 1.03 KB
Contents
class Ppl::Service::PhoneNumber attr_writer :storage def add(contact, number, options) phone_number = Ppl::Entity::PhoneNumber.new(number) contact.phone_numbers << phone_number update_phone_number(contact, phone_number, options) @storage.save_contact(contact) end def update(contact, number, options) matching_numbers = contact.phone_numbers.select { |p| p.number == number } matching_numbers.each { |mn| update_phone_number(contact, mn, options) } @storage.save_contact(contact) end def remove(contact, number) contact.phone_numbers.select! do |phone_number| phone_number.number != number end @storage.save_contact(contact) end private def update_phone_number(contact, phone_number, options) if options[:type] phone_number.type = options[:type] end if options[:preferred] == true contact.phone_numbers.each { |p| p.preferred = (p.number == phone_number.number) } elsif options[:preferred] == false phone_number.preferred = false end end end
Version data entries
13 entries across 13 versions & 1 rubygems