diff options
author | Snuggs <rstovall@innovative-studios.com> | 2010-10-16 17:40:45 -0400 |
---|---|---|
committer | Snuggs <rstovall@innovative-studios.com> | 2010-10-16 17:43:44 -0400 |
commit | 7959e55ead84be096247d9622404d1c60ca21c88 (patch) | |
tree | d6374c27ddae85aeeaa835a4fe6c59c1fcf2ad05 | |
parent | 3fcfcd7b80ea9cbb164487922a33eca5609602a6 (diff) | |
download | rails-7959e55ead84be096247d9622404d1c60ca21c88.tar.gz rails-7959e55ead84be096247d9622404d1c60ca21c88.tar.bz2 rails-7959e55ead84be096247d9622404d1c60ca21c88.zip |
Created syntactic sugar Table(...) method
-rw-r--r-- | History.txt | 6 | ||||
-rw-r--r-- | lib/arel/table.rb | 6 | ||||
-rw-r--r-- | spec/table_spec.rb | 23 |
3 files changed, 33 insertions, 2 deletions
diff --git a/History.txt b/History.txt index bcec68b6cf..7a66436709 100644 --- a/History.txt +++ b/History.txt @@ -1,3 +1,9 @@ +== 2.0.0 / 2010-08-01 +* Enhancements + + * Recreate library using the Visitor pattern. + http://en.wikipedia.org/wiki/Visitor_pattern + == 0.3.0 / 2010-03-10 * Enhancements diff --git a/lib/arel/table.rb b/lib/arel/table.rb index 171d165bc2..76ced079ba 100644 --- a/lib/arel/table.rb +++ b/lib/arel/table.rb @@ -1,4 +1,8 @@ -module Arel +def Table(name, engine = Arel::Table.engine) + Arel::Table.new(name, engine) +end + +module Arel class Table include Arel::Crud diff --git a/spec/table_spec.rb b/spec/table_spec.rb index d0ba46ae56..77a600877e 100644 --- a/spec/table_spec.rb +++ b/spec/table_spec.rb @@ -1,6 +1,27 @@ require 'spec_helper' -module Arel +describe '#Table' do + it 'creates a base relation variable' do + name = :foo + Table(name) == Arel::Table.new(name) + end + + it 'should have a default engine' do + Table(:foo).engine.should == Arel::Table.engine + end + + it 'can take an engine' do + engine = Arel::Table.engine + Table(:foo, engine).engine.should be engine + end + it 'can take an options hash' do + engine = Arel::Table.engine + options = { :engine => engine } + Table(:foo, options).engine.should be engine + end +end + +module Arel describe Table do before do @relation = Table.new(:users) |