Sha256: c872e9160f27fc57ba2e68c06081c1df5e475a3328d060f7d82951027835b6e1
Contents?: true
Size: 490 Bytes
Versions: 3
Compression:
Stored size: 490 Bytes
Contents
module Structural class Hashifier def self.hashify(data) new(data).hashify end def initialize(data) @data = data end def hashify Hash[data.map { |k, v| [ k.to_s, as_data(v) ] }] end private def as_data(v) case v when Structural::Model then v.data when Array then v.first.is_a?(Structural::Model) ? v.map(&:data) : v when Hash then Hashifier.hashify(v) else v end end attr_reader :data end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
structural-0.0.3 | lib/structural/hashifier.rb |
structural-0.0.2 | lib/structural/hashifier.rb |
structural-0.0.1 | lib/structural/hashifier.rb |