Class: DataMapper::Mappings::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/data_mapper/mappings/schema.rb

Instance Method Summary collapse

Constructor Details

#initialize(database) ⇒ Schema

Returns a new instance of Schema.



8
9
10
11
# File 'lib/data_mapper/mappings/schema.rb', line 8

def initialize(database)
  @database = database
  @tables = Hash.new { |h,k| h[k] = Table.new(@database, k) }
end

Instance Method Details

#[](klass) ⇒ Object



13
14
15
16
17
# File 'lib/data_mapper/mappings/schema.rb', line 13

def [](klass)
  @tables[klass]
rescue
  raise "#{klass.inspect} can't be mapped to a table"
end

#eachObject



19
20
21
22
23
# File 'lib/data_mapper/mappings/schema.rb', line 19

def each
  @tables.values.each do |table|
    yield table
  end
end