lib/ridgepole/dsl_parser.rb in ridgepole-0.7.3.beta vs lib/ridgepole/dsl_parser.rb in ridgepole-0.7.3.beta2
- old
+ new
@@ -1,30 +1,32 @@
-class Ridgepole::DSLParser
- def initialize(options = {})
- @options = options
- end
+module Ridgepole
+ class DSLParser
+ def initialize(options = {})
+ @options = options
+ end
- def parse(dsl, opts = {})
- definition, execute = Context.eval(dsl, opts)
- check_orphan_index(definition)
- check_orphan_foreign_key(definition)
- [definition, execute]
- end
+ def parse(dsl, opts = {})
+ definition, execute = Context.eval(dsl, opts)
+ check_orphan_index(definition)
+ check_orphan_foreign_key(definition)
+ [definition, execute]
+ end
- private
+ private
- def check_orphan_index(definition)
- definition.each do |table_name, attrs|
- if attrs[:indices] and not attrs[:definition]
- raise "Table `#{table_name}` to create the index is not defined: #{attrs[:indices].keys.join(',')}"
+ def check_orphan_index(definition)
+ definition.each do |table_name, attrs|
+ if attrs[:indices] && !(attrs[:definition])
+ raise "Table `#{table_name}` to create the index is not defined: #{attrs[:indices].keys.join(',')}"
+ end
end
end
- end
- def check_orphan_foreign_key(definition)
- definition.each do |table_name, attrs|
- if attrs[:foreign_keys] and not attrs[:definition]
- raise "Table `#{table_name}` to create the foreign key is not defined: #{attrs[:foreign_keys].keys.join(',')}"
+ def check_orphan_foreign_key(definition)
+ definition.each do |table_name, attrs|
+ if attrs[:foreign_keys] && !(attrs[:definition])
+ raise "Table `#{table_name}` to create the foreign key is not defined: #{attrs[:foreign_keys].keys.join(',')}"
+ end
end
end
end
end