Sha256: 677d0923766d97abf224dc83fc5881177b599637b9591aac424c955897631d2c

Contents?: true

Size: 1.46 KB

Versions: 17

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 unless respond_to?(:custom_node_parser, true)

          method(:custom_node_parser)
        end

        def custom_node_parser_before_block
          return 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

17 entries across 17 versions & 1 rubygems

Version Path
eco-helpers-3.0.21 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.20 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.19 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.18 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.17 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.16 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.15 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.14 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.13 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.12 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.11 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.10 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.9 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.8 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.7 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.6 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb
eco-helpers-3.0.5 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list/converter/parser.rb