Sha256: 3f93ebcecca805078f93b50725d8ed07c32a83d8671a1f69cfccb2251ead4577
Contents?: true
Size: 797 Bytes
Versions: 2
Compression:
Stored size: 797 Bytes
Contents
require_relative '../serialization/to_wire' class Array def to_tsv to_wire.join("\t") end end module Gorillib module Model def to_wire(options={}) compact_attributes.merge(:_type => self.class.typename).inject({}) do |acc, (key,attr)| acc[key] = attr.respond_to?(:to_wire) ? attr.to_wire(options) : attr acc end end def as_json(*args) to_wire(*args) ; end def to_json(options={}) MultiJson.dump(to_wire(options), options) end def to_tsv(options={}) attributes.map do |key, attr| attr.respond_to?(:to_wire) ? attr.to_wire(options) : attr end.join("\t") end module ClassMethods def from_tuple(*vals) receive Hash[field_names[0..vals.length-1].zip(vals)] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gorillib-0.6.0 | lib/gorillib/model/serialization.rb |
gorillib-0.5.2 | lib/gorillib/model/serialization.rb |