ActiveModel::Serialization
module ActiveModel::Serialization
Active Model Serialization
Provides a basic serialization to a #serializable_hash for your objects.
A minimal implementation could be:
class Person include ActiveModel::Serialization attr_accessor :name def attributes {'name' => nil} end end
Which would provide you with:
person = Person.new person.serializable_hash # => {"name"=>nil} person.name = "Bob" person.serializable_hash # => {"name"=>"Bob"}
An attributes
hash must be defined and should contain any attributes you need to be serialized. Attributes must be strings, not symbols. When called, serializable hash wil