Sha256: 4547bdec2e6985f79882c89a32214f00dc31f134d83e80ff47cb094ad754c0ff
Contents?: true
Size: 1.09 KB
Versions: 17
Compression:
Stored size: 1.09 KB
Contents
require_relative 'converter/parser' require_relative 'converter/input' require_relative 'converter/node_attr_maps' require_relative 'converter/discarded' module Eco::API::UseCases::GraphQL::Samples::Location::Service module TreeToList module Converter include Parser include Input include NodeAttrMaps include Discarded private # Converter. Transforms an org tagtree to a list of hash nodes # @note it ensures `DISCARDED_NODES` are excluded # @return [Array<Hash>] list of hash nodes def as_nodes_json(tree = input_tagtree) tree.reject do |node| discarded?(node.id) end.each_with_object([]) do |node, list| list << node.as_json(include_children: false).transform_keys do |key| next key unless node_attr_maps.key?(key) node_attr_maps[key] end.tap do |node_hash| node_parser_block&.call(node_hash, node) yield(node_hash, node) if block_given? end end.compact.reject(&:empty?) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems