Permalink
Browse files

fix schema generation changes

  • Loading branch information...
rcarver committed Mar 19, 2012
1 parent a409239 commit caa4f34319c25ab63c18acbf2e6a43a05c512bdf
Showing with 10 additions and 8 deletions.
  1. +7 −5 lib/orel/schema_generator.rb
  2. +3 −3 spec/schema_generator_spec.rb
@@ -20,13 +20,15 @@ def self.class_creation_statements(classes)
# Returns an Array of Strings.
def self.creation_statements(headings)
tables = headings.map { |heading|
- Orel::SchemaGenerator::Table.new(heading.namer, heading)
+ Orel::SchemaGenerator::Table.new(heading, heading.namer)
}
foreign_keys = headings.map { |heading|
heading.foreign_keys.map { |foreign_key|
- parent_table = Orel::SchemaGenerator::Table.new(heading.namer, foreign_key.parent_heading)
- child_table = Orel::SchemaGenerator::Table.new(heading.namer, foreign_key.child_heading)
+ parent_heading = foreign_key.parent_heading
+ child_heading = foreign_key.child_heading
+ parent_table = Orel::SchemaGenerator::Table.new(parent_heading, parent_heading.namer)
+ child_table = Orel::SchemaGenerator::Table.new(child_heading, child_heading.namer)
parent_attributes = foreign_key.parent_key.attributes
child_attributes = foreign_key.child_key.attributes
Orel::SchemaGenerator::ForeignKey.new(
@@ -58,9 +60,9 @@ def quote_table_name(name)
class Table
include Quoting
- def initialize(relation_namer, heading)
- @relation_namer = relation_namer
+ def initialize(heading, relation_namer)
@heading = heading
+ @relation_namer = relation_namer
end
attr_reader :relation_namer
def name
@@ -3,11 +3,11 @@
describe Orel::SchemaGenerator::Table do
let(:klass) { UsersAndThings::User }
- let(:namer) { Orel::Relation::Namer.new("name", :pluralize => true) }
+ let(:namer) { Orel::Relation::Namer.new("user", :pluralize => true) }
- subject { described_class.new(namer, klass.get_heading) }
+ subject { described_class.new(klass.get_heading, namer) }
- its(:name) { should == :users_and_things_users }
+ its(:name) { should == :users }
specify "#create_statement"
end

0 comments on commit caa4f34

Please sign in to comment.