Sha256: 3b1f945360188efc23760bd83901ad2df66d7286d8c9788973724edfa0e18653

Contents?: true

Size: 841 Bytes

Versions: 39

Compression:

Stored size: 841 Bytes

Contents

class Ridgepole::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

  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(',')}"
      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(',')}"
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
ridgepole-0.7.3.beta lib/ridgepole/dsl_parser.rb
ridgepole-0.7.2 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.2.beta lib/ridgepole/dsl_parser.rb
ridgepole-0.7.1 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.1.beta5 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.1.beta4 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.1.beta3 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.1.beta2 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.1.beta lib/ridgepole/dsl_parser.rb
ridgepole-0.7.0 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.0.rc1 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.0.beta22 lib/ridgepole/dsl_parser.rb
ridgepole-0.6.6 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.0.beta21 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.0.beta20 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.0.beta19 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.0.beta18 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.0.beta17 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.0.beta16 lib/ridgepole/dsl_parser.rb
ridgepole-0.7.0.beta15 lib/ridgepole/dsl_parser.rb