Sha256: 4cc1edcda2ed2418cd220fc819fa40be97c92b387f206e2e8f4b0262feda09f2
Contents?: true
Size: 1014 Bytes
Versions: 4
Compression:
Stored size: 1014 Bytes
Contents
require 'representable/binding' module Representable module Hash class Binding < Representable::Binding def self.build_for(definition, *args) # TODO: remove default arg. # puts "@@@build@@ #{definition.inspect}" return Collection.new(definition, *args) if definition.array? return Hash.new(definition, *args) if definition.hash? new(definition, *args) end def read(hash) return FragmentNotFound unless hash.has_key?(as) # DISCUSS: put it all in #read for performance. not really sure if i like returning that special thing. hash[as] # fragment end def write(hash, fragment) hash[as] = fragment end def serialize_method :to_hash end def deserialize_method :from_hash end class Collection < self include Representable::Binding::Collection end class Hash < self include Representable::Binding::Hash end end end end
Version data entries
4 entries across 4 versions & 1 rubygems