Class: DslContext

Inherits:
Object
  • Object
show all
Defined in:
lib/DSLContext.rb

Class Method Summary collapse

Class Method Details

.bubble(*methods) ⇒ Object



23
24
25
26
27
# File 'lib/DSLContext.rb', line 23

def self.bubble(*methods)
  methods.each do |method|
    define_method(method) {}
  end
end

.execute(*args) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/DSLContext.rb', line 2

def self.execute(*args)
  rules = polish_text(args[0])
	#significant change to allow class instance variables to be set on the initialize, ahead
	#of the evaluation of the DSL - allows dynamic props to be sent to the class
	#see VPMSProductSchemaInterpreter, which gets a param from the package interpreter
  inst = (args.length > 1) ? self.new(args.slice(1,1)) : self.new
  rules.each do |rule|
    result = inst.instance_eval(rule)
    #passes results as parm into code that was passed with call to execute (if any was)
    yield result if block_given?
  end
  inst.getResult
end

.polish_text(text) ⇒ Object



16
17
18
19
20
21
# File 'lib/DSLContext.rb', line 16

def self.polish_text(text)
  rules = text.split("\n")
  rules.collect do |rule|
    rule << " "
  end
end