aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/models/contact.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/test/models/contact.rb')
-rw-r--r--activemodel/test/models/contact.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/activemodel/test/models/contact.rb b/activemodel/test/models/contact.rb
index 7bfc542afb..bcfd267a34 100644
--- a/activemodel/test/models/contact.rb
+++ b/activemodel/test/models/contact.rb
@@ -1,15 +1,20 @@
class Contact
extend ActiveModel::Naming
include ActiveModel::Conversion
+ include ActiveModel::Validations
+
+ include ActiveModel::Serializers::JSON
+ include ActiveModel::Serializers::Xml
attr_accessor :id, :name, :age, :created_at, :awesome, :preferences
+ attr_accessor :address, :friends, :contact
def social
%w(twitter github)
end
def network
- {:git => :github}
+ { git: :github }
end
def initialize(options = {})
@@ -23,4 +28,14 @@ class Contact
def persisted?
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