Sha256: 68c5d470bada6cf48414ede01852bd1e43dec5855663980a503425a2d96d72fe
Contents?: true
Size: 517 Bytes
Versions: 1
Compression:
Stored size: 517 Bytes
Contents
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 to_json(options={}) MultiJson.dump(to_wire(options), options) end alias_method(:as_json, :to_wire) module ClassMethods def from_tuple(*vals) receive Hash[field_names[0..vals.length].zip(vals)] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gorillib-0.4.0pre | lib/gorillib/model/serialization.rb |