Sha256: 7cd1b61aabac84eaa06c3949e007897034def6dbb84d91b71ddbe0a1ad9ea2e2
Contents?: true
Size: 646 Bytes
Versions: 3
Compression:
Stored size: 646 Bytes
Contents
class Array def to_tsv join("\t") end end module Gorillib module Model def to_wire(options={}) 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 attribute_values.map(&:to_s).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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gorillib-0.5.0 | lib/gorillib/model/serialization.rb |
gorillib-0.4.2 | lib/gorillib/model/serialization.rb |
gorillib-0.4.2pre | lib/gorillib/model/serialization.rb |