Module: OodCluster::JsonSerializer
Overview
Helper methods for serializing/deserializing an object from JSON
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Sets class methods in any class that includes JsonSerializer.
Instance Method Summary collapse
-
#to_json(*args) ⇒ Object
Serialize object into a json string.
Class Method Details
.included(base) ⇒ Object
Sets class methods in any class that includes OodCluster::JsonSerializer
7 8 9 |
# File 'lib/ood_cluster/json_serializer.rb', line 7 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#to_json(*args) ⇒ Object
Serialize object into a json string
22 23 24 25 26 27 |
# File 'lib/ood_cluster/json_serializer.rb', line 22 def to_json(*args) { JSON.create_id => self.class.name, 'data' => self.to_h }.to_json(*args) end |