Module: MadderLib::KernelMethods
- Defined in:
- lib/madderlib/core.rb
Overview
KernelMethods
A Module containing MadderLib methods which are injected into the Kernel scope / namespace. Requiring the gem has the side-effect of injecting these methods.
Instance Method Summary collapse
-
#madderlib(*args, &block) ⇒ Object
A proxy for MadderLib::Builder.new .
-
#madderlib_grammar ⇒ Object
A proxy for MadderLib::Grammar.get_instance .
Instance Method Details
#madderlib(*args, &block) ⇒ Object
A proxy for MadderLib::Builder.new . It returns a constructed Builder.
The resulting Builder is automatically added to the active Grammar. The active grammar can be accessed via madderlib_grammar .
Please see MadderLib::Builder for extensive examples of how a Builder itself is put to use
Examples:
builder = madderlib do
say 'no id'
end
madderlib_grammar.builders.include?(builder).should be_true
madderlib_grammar.builder_map.values.include?(builder).should_not be_true
builder = madderlib :id do
say 'has id'
end
madderlib_grammar.builders.include?(builder).should be_true
madderlib_grammar.builder_map.values.include?(builder).should be_true
55 56 57 58 59 60 |
# File 'lib/madderlib/core.rb', line 55 def madderlib(*args, &block) builder = Builder.new *args madderlib_grammar.add builder builder.extend &block end |
#madderlib_grammar ⇒ Object
A proxy for MadderLib::Grammar.get_instance . It returns the active Grammar
See: madderlib
66 67 68 69 |
# File 'lib/madderlib/core.rb', line 66 def madderlib_grammar # the current instance we're working with Grammar.get_instance end |