mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Table.new can take a hash for the second param
This commit is contained in:
parent
bfe0348889
commit
5d7cad6079
2 changed files with 16 additions and 3 deletions
|
@ -6,9 +6,10 @@ module Arel
|
||||||
attr_reader :name, :engine
|
attr_reader :name, :engine
|
||||||
|
|
||||||
def initialize name, engine = Table.engine
|
def initialize name, engine = Table.engine
|
||||||
@name = name
|
@name = name
|
||||||
@engine = engine
|
@engine = engine
|
||||||
@columns = nil
|
@engine = engine[:engine] if Hash === engine
|
||||||
|
@columns = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def tm
|
def tm
|
||||||
|
|
|
@ -6,6 +6,18 @@ module Arel
|
||||||
@relation = Table.new(:users)
|
@relation = Table.new(:users)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'new' do
|
||||||
|
it 'should accept an engine' do
|
||||||
|
rel = Table.new :users, 'foo'
|
||||||
|
rel.engine.should == 'foo'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should accept a hash' do
|
||||||
|
rel = Table.new :users, :engine => 'foo'
|
||||||
|
rel.engine.should == 'foo'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'where' do
|
describe 'where' do
|
||||||
it "returns a tree manager" do
|
it "returns a tree manager" do
|
||||||
manager = @relation.where @relation[:id].eq 1
|
manager = @relation.where @relation[:id].eq 1
|
||||||
|
|
Loading…
Reference in a new issue