Sha256: bd83e4a1576221fa1c85665646450fdd7b4fade2c7cb5947d3990e8841739746
Contents?: true
Size: 1 KB
Versions: 5
Compression:
Stored size: 1 KB
Contents
module Representable class Binding attr_reader :definition def initialize(definition) @definition = definition end # Usually called in concrete ObjectBinding in #write and #read. module Hooks private # Must be called in serialization of concrete ObjectBinding. def write_object(object) object end # Creates a typed property instance. def create_object definition.sought_type.new end end # Hooks into #write_object and #create_object to extend typed properties # at runtime. module Extend private # Extends the object with its representer before serialization. def write_object(object) extend_for(super) end def create_object extend_for(super) end def extend_for(object) # TODO: test me. if mod = definition.representer_module object.extend(mod) end object end end end end
Version data entries
5 entries across 5 versions & 1 rubygems