Sha256: 5800e33961947b9697b7d68aa3bf53eeb8f87af94b607ff52a2131a62d98059a
Contents?: true
Size: 833 Bytes
Versions: 17
Compression:
Stored size: 833 Bytes
Contents
module Attributor class FieldSelector class Transformer < Parslet::Transform rule(field: simple(:field_token), children: subtree(:children_tree)) do cs = if children_tree.empty? true else children_tree.each_with_object({}) do |item, hash| hash.merge! item end end { field_token.to_sym => cs } end rule(csv: subtree(:csv_tree)) do case csv_tree when ::Hash csv_tree when Array csv_tree.each_with_object({}) do |item, hash| hash.merge! item end else raise "Oops...didn't know this could happen! (this is not a Hash or an Array?). Got a #{csv_tree.class.name} : #{csv_tree.inspect}" end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems