Sha256: 3884cee155f903280d01b700508ce5d6ed51b6d96e0ff924e15a4f877694817a
Contents?: true
Size: 438 Bytes
Versions: 14
Compression:
Stored size: 438 Bytes
Contents
class Serializers class Base @@structures = {} def self.structure(type, &blk) @@structures["#{self.name}::#{type}"] = blk end def initialize(type) @type = type end def serialize(object) object.respond_to?(:map) ? object.map{|item| serializer.call(item)} : serializer.call(object) end private def serializer @@structures["#{self.class.name}::#{@type}"] end end end
Version data entries
14 entries across 14 versions & 1 rubygems