1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activemodel/test/models/contact.rb

43 lines
737 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class Contact
2012-10-27 00:03:36 -04:00
extend ActiveModel::Naming
include ActiveModel::Conversion
include ActiveModel::Validations
include ActiveModel::Serializers::JSON
attr_accessor :id, :name, :age, :created_at, :awesome, :preferences
attr_accessor :address, :friends, :contact
def social
%w(twitter github)
end
def network
{ git: :github }
end
def initialize(options = {})
options.each { |name, value| send("#{name}=", value) }
end
def pseudonyms
nil
end
def persisted?
2010-02-22 02:45:41 -05:00
id
end
def attributes=(hash)
hash.each do |k, v|
instance_variable_set("@#{k}", v)
end
end
def attributes
instance_values.except("address", "friends", "contact")
end
end