Sha256: 2f1a9782bf9a09d58fd72b768a3c57c19d7953756f3ce53d564e4bac5d4dc421

Contents?: true

Size: 1011 Bytes

Versions: 3

Compression:

Stored size: 1011 Bytes

Contents

# frozen_string_literal: true

module Grumlin
  class AnonymousStep
    attr_reader :name, :args, :previous_step

    # TODO: add other steps
    SUPPORTED_STEPS = %w[E V addE addV as by coalesce count dedup drop elementMap emit fold from group groupCount has
                         hasId hasLabel hasNot in inV label limit not order out outE path project property repeat select
                         to unfold union valueMap values where].freeze

    def initialize(name, *args, previous_step: nil)
      @name = name
      @previous_step = previous_step
      @args = args
    end

    SUPPORTED_STEPS.each do |step|
      define_method(step) do |*args|
        add_step(step, args)
      end
    end

    def inspect
      bytecode.inspect
    end

    alias to_s inspect

    def bytecode(no_return: false)
      @bytecode ||= Bytecode.new(self, no_return: no_return)
    end

    private

    def add_step(step_name, args)
      self.class.new(step_name, *args, previous_step: self)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
grumlin-0.11.0 lib/grumlin/anonymous_step.rb
grumlin-0.10.1 lib/grumlin/anonymous_step.rb
grumlin-0.10.0 lib/grumlin/anonymous_step.rb