Sha256: 92c2d9715f577e8ebab7e253481d033170737bf7b10b301e4d80fb7c5ea19390
Contents?: true
Size: 467 Bytes
Versions: 6
Compression:
Stored size: 467 Bytes
Contents
module Id 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 Id::Model then v.data when Array then v.first.is_a?(Id::Model) ? v.map(&:data) : v when Hash then Hashifier.hashify(v) else v end end attr_reader :data end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
id-0.0.12 | lib/id/hashifier.rb |
id-0.0.11 | lib/id/hashifier.rb |
id-0.0.10 | lib/id/hashifier.rb |
id-0.0.9 | lib/id/hashifier.rb |
id-0.0.8 | lib/id/hashifier.rb |
id-0.0.7 | lib/id/hashifier.rb |