2017-07-16 13:11:16 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2009-06-28 23:12:10 -04:00
|
|
|
class Contact
|
2012-10-27 00:03:36 -04:00
|
|
|
extend ActiveModel::Naming
|
2010-02-21 02:47:37 -05:00
|
|
|
include ActiveModel::Conversion
|
2014-08-28 03:56:53 -04:00
|
|
|
include ActiveModel::Validations
|
|
|
|
|
|
|
|
include ActiveModel::Serializers::JSON
|
2010-02-21 02:47:37 -05:00
|
|
|
|
2010-02-21 05:09:21 -05:00
|
|
|
attr_accessor :id, :name, :age, :created_at, :awesome, :preferences
|
2014-08-28 03:56:53 -04:00
|
|
|
attr_accessor :address, :friends, :contact
|
2009-07-22 22:06:34 -04:00
|
|
|
|
2010-04-29 17:39:05 -04:00
|
|
|
def social
|
|
|
|
%w(twitter github)
|
|
|
|
end
|
|
|
|
|
|
|
|
def network
|
2013-05-01 20:10:06 -04:00
|
|
|
{ git: :github }
|
2010-04-29 17:39:05 -04:00
|
|
|
end
|
|
|
|
|
2009-07-22 22:06:34 -04:00
|
|
|
def initialize(options = {})
|
2020-10-26 11:38:28 -04:00
|
|
|
options.each { |name, value| public_send("#{name}=", value) }
|
2009-07-22 22:06:34 -04:00
|
|
|
end
|
2010-02-21 02:47:37 -05:00
|
|
|
|
2011-03-03 15:43:42 -05:00
|
|
|
def pseudonyms
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2010-02-21 05:09:21 -05:00
|
|
|
def persisted?
|
2010-02-22 02:45:41 -05:00
|
|
|
id
|
2010-02-21 02:47:37 -05:00
|
|
|
end
|
2014-08-28 03:56:53 -04:00
|
|
|
|
|
|
|
def attributes=(hash)
|
|
|
|
hash.each do |k, v|
|
|
|
|
instance_variable_set("@#{k}", v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def attributes
|
|
|
|
instance_values.except("address", "friends", "contact")
|
|
|
|
end
|
2009-06-28 23:12:10 -04:00
|
|
|
end
|