Sha256: bb4d082c2eb8f1a56bd073e1de2a7a06c11ceb6afd33384ffaf72c4037cca281

Contents?: true

Size: 1.46 KB

Versions: 13

Compression:

Stored size: 1.46 KB

Contents

module Eco::API::UseCases::GraphQL::Samples::Location::Service
  module TreeToList
    module Converter
      module Parser
        private

        # Adds up to the generic_node_parser
        # def custom_node_parser(node_hash)
        #   node_hash.each do |key, val|
        #   end
        # end

        def node_parser_block
          return @node_parser_block if instance_variable_defined?(:@node_parser_block)
          custom_before = custom_node_parser_before_block
          custom_after  = custom_node_parser_block
          @node_parser_block = proc do |node_hash, node|
            node_hash.tap do
              custom_before&.call(node_hash, node)
              default_node_parse(node_hash, node)
              custom_after&.call(node_hash, node)
            end
          end
        end

        # Grabs the custom node parser that runs after the generic one
        def custom_node_parser_block
          return nil unless respond_to?(:custom_node_parser, true)
          method(:custom_node_parser)
        end

        def custom_node_parser_before_block
          return nil unless respond_to?(:custom_node_parser_before, true)
          method(:custom_node_parser_before)
        end

        # Generic parsing
        def default_node_parse(node_hash, _node)
          class_ids = to_classification_ids(node_hash['classifications'])
          node_hash['classifications'] = class_ids
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
eco-helpers-3.0.4 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.3 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.2 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.1 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.0 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.25 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.24 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.23 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.22 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.21 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.20 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.19 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.18 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb