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.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/activemodel/test/models/contact.rb b/activemodel/test/models/contact.rb
new file mode 100644
index 0000000000..c40a6d6f0e
--- /dev/null
+++ b/activemodel/test/models/contact.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+class Contact
+ 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?
+ 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