Sha256: bf804f53fc2e724768108fb64af1478556c925fa230fc9b373f7332260bac9b0

Contents?: true

Size: 734 Bytes

Versions: 3

Compression:

Stored size: 734 Bytes

Contents

# frozen_string_literal: true

module Grumlin
  module Sugar
    # TODO: how to use it in specs?
    HELPERS = [
      Grumlin::U,
      Grumlin::T,
      Grumlin::P,
      Grumlin::Pop,
      Grumlin::Order
    ].freeze

    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      def const_missing(name)
        helper = HELPERS.find { |h| h.const_defined?(name) }
        super if helper.nil?

        const_set(name, helper)
      end
    end

    def const_missing(name)
      helper = HELPERS.find { |h| h.const_defined?(name) }
      super if helper.nil?

      const_set(name, helper)
    end

    def __
      Grumlin::U
    end

    def g
      Grumlin::Traversal.new
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
grumlin-0.4.0 lib/grumlin/sugar.rb
grumlin-0.3.0 lib/grumlin/sugar.rb
grumlin-0.2.0 lib/grumlin/sugar.rb