Sha256: ecea761b6ea14765a6d76a8171d7c22b4fb5543eec637a97720032faa5df939d

Contents?: true

Size: 1.43 KB

Versions: 10

Compression:

Stored size: 1.43 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_hash.tap do
              custom_before&.call(node_hash)
              default_node_parse(node_hash)
              custom_after&.call(node_hash)
            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)
          class_ids = to_classification_ids(node_hash['classifications'])
          node_hash['classifications'] = class_ids
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
eco-helpers-2.7.17 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.16 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.15 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.14 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.13 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.12 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.4 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.2 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.1 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-2.7.0 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb