Sha256: 5de763c287cdbdced4ef4e80c43f3fcbd163cf4e9cf969b680af61cb51bdc4cf

Contents?: true

Size: 827 Bytes

Versions: 1

Compression:

Stored size: 827 Bytes

Contents

# frozen_string_literal: true

module Damn
  module Legacy
    module DSL
      def const_missing(name)
        const_set(name, Class.new)
      end

      def meth(methods, _opts = {})
        Store.instance.add_meth(self, methods)
      end

      def step(&block)
        raise ArgumentError, "No block provided" unless block_given?

        val = block.call
        if !val.nil? && !Store.instance.stack.empty? && self == Store.instance.stack.first[1]
          each do |key|
            Store.instance.add(key, val)
          end
        else
          head, = Store.instance.stack.shift
          if head && is_a?(Array)
            each do |key|
              Store.instance.add(key, head)
            end
          end
        end
        self
      end

      def plot
        Mermaid.call
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
damn-legacy-0.0.1 lib/damn/legacy/dsl.rb