Sha256: 65cd63f7833d14d4cdf016edde4acfaafb0af3ff09da31e80ff286a8bde0676b
Contents?: true
Size: 502 Bytes
Versions: 2
Compression:
Stored size: 502 Bytes
Contents
module Hari class Node < Entity module Serialization def from_source(source) return if source.blank? hash = Yajl::Parser.parse(source) klass = hash['id'].split('#').first.camelize.constantize attrs = hash.inject({}) do |buffer, (key, value)| if prop = klass.properties.find { |p| p.name == key } buffer[key] = prop.desserialize(value) end buffer end klass.new attrs end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hari-0.0.4 | lib/hari/node/serialization.rb |
hari-0.0.3 | lib/hari/node/serialization.rb |