Module: Jade::Parsing::Combinators::Dsl

Included in:
Jade::Parsing, Jade::Parsing::Combinators, Token, Type
Defined in:
lib/jade/parsing/combinators.rb

Instance Method Summary collapse

Instance Method Details

#parser(name, private: false, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/jade/parsing/combinators.rb', line 7

def parser(name, private: false, &block)
  builder = :"_build_#{name}"
  define_method(builder, &block)
  send(:private, builder)
  module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
    def #{name}
      @#{name} ||= #{builder}
    end
  RUBY
  send(:private, name) if private
end