module OodCluster::JsonSerializer
Helper methods for serializing/deserializing an object from JSON
Public Class Methods
included(base)
click to toggle source
Sets class methods in any class that includes {JsonSerializer}
# File lib/ood_cluster/json_serializer.rb, line 7 def self.included(base) base.extend(ClassMethods) end
Public Instance Methods
to_json(*args)
click to toggle source
Serialize object into a json string
# 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