lib/ridgepole/dsl_parser.rb in ridgepole-0.3.9 vs lib/ridgepole/dsl_parser.rb in ridgepole-0.4.0
- old
+ new
@@ -44,11 +44,17 @@
@__definition = {}
end
def self.eval(dsl, opts = {})
ctx = self.new(opts)
- ctx.instance_eval(dsl)
+
+ if opts[:path]
+ ctx.instance_eval(dsl, opts[:path])
+ else
+ ctx.instance_eval(dsl)
+ end
+
ctx.__definition
end
def create_table(table_name, options = {})
table_definition = TableDefinition.new
@@ -81,12 +87,12 @@
def require(file)
schemafile = File.join(@__working_dir, file)
if File.exist?(schemafile)
- instance_eval(File.read(schemafile))
+ instance_eval(File.read(schemafile), schemafile)
elsif File.exist?(schemafile + '.rb')
- instance_eval(File.read(schemafile + '.rb'))
+ instance_eval(File.read(schemafile + '.rb'), schemafile + '.rb')
else
Kernel.require(file)
end
end
end