Class: Lustr::DSL
- Inherits:
-
BlankSlate
- Object
- BlankSlate
- Lustr::DSL
- Defined in:
- lib/lustr/dsl.rb
Class Method Summary collapse
Instance Method Summary collapse
- #gadget(options) ⇒ Object
-
#initialize(parse_context, eval_context) ⇒ DSL
constructor
A new instance of DSL.
- #involve(path) ⇒ Object
- #is_runtime? ⇒ Boolean
Constructor Details
#initialize(parse_context, eval_context) ⇒ DSL
Returns a new instance of DSL.
28 29 30 31 32 |
# File 'lib/lustr/dsl.rb', line 28 def initialize(parse_context, eval_context) @parse_context=parse_context @eval_context=eval_context @involved=[] end |
Class Method Details
.add_dsl_method(*symbols) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/lustr/dsl.rb', line 18 def self.add_dsl_method(*symbols) symbols.each do |sym| class_eval <<EOF def #{sym}(options={}) @parse_context.add_builder(:#{sym}, options) { yield if block_given? } end EOF end end |
Instance Method Details
#gadget(options) ⇒ Object
41 42 43 44 45 |
# File 'lib/lustr/dsl.rb', line 41 def gadget() builder=GadgetBuilder.new() @parse_context.attach_builder(builder, [:name]) { yield if block_given? } Lustr.add_dsl_handler([:name].to_sym, builder) end |
#involve(path) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/lustr/dsl.rb', line 34 def involve(path) if !@involved.include?(path) @involved << path self.instance_eval(File.new(path).read, path) end end |
#is_runtime? ⇒ Boolean
47 48 49 |
# File 'lib/lustr/dsl.rb', line 47 def is_runtime? @eval_context.is_runtime? end |