Sha256: 4ea08b1c881da6db7302347f1c215fd69afcdb866db25a6cc20806dcf1a54532
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
module XeroGateway class Contact attr_accessor :contact_id, :contact_number, :status, :name, :email, :addresses, :phones, :updated_at def initialize(params = {}) params = {}.merge(params) params.each do |k,v| self.instance_variable_set("@#{k}", v) ## create and initialize an instance variable for this key/value pair self.send("#{k}=", v) end @phones ||= [] @addresses ||= [] end def address=(address) self.addresses = [address] end def address self.addresses[0] ||= Address.new end def phone=(phone) self.phones = [phone] end def phone if @phones.size > 1 @phones.detect {|p| p.phone_type == 'DEFAULT'} || phones[0] else @phones[0] ||= Phone.new end end def ==(other) [:contact_number, :status, :name, :email, :addresses, :phones].each do |field| return false if send(field) != other.send(field) end return true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tlconnor-xero_gateway-1.0.2 | lib/xero_gateway/contact.rb |