diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-12 15:22:26 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-12 15:22:26 -0700 |
commit | 4127484bc172900f0817d6adda666a1397ff038e (patch) | |
tree | baf9b2fc45f24b48a5c03635408d1a84e20eb311 | |
parent | 196b4e05b7390ac31e12a17ae224b1cf35e4becd (diff) | |
download | rails-4127484bc172900f0817d6adda666a1397ff038e.tar.gz rails-4127484bc172900f0817d6adda666a1397ff038e.tar.bz2 rails-4127484bc172900f0817d6adda666a1397ff038e.zip |
adding first node
-rw-r--r-- | lib/arel.rb | 1 | ||||
-rw-r--r-- | lib/arel/attributes/attribute.rb | 9 | ||||
-rw-r--r-- | lib/arel/nodes.rb | 1 | ||||
-rw-r--r-- | lib/arel/nodes/equality.rb | 12 | ||||
-rw-r--r-- | spec/arel/attributes/attribute_spec.rb | 17 |
5 files changed, 37 insertions, 3 deletions
diff --git a/lib/arel.rb b/lib/arel.rb index afab11cd91..b322e930be 100644 --- a/lib/arel.rb +++ b/lib/arel.rb @@ -1,6 +1,7 @@ require 'arel/version' require 'arel/table' require 'arel/attributes' +require 'arel/nodes' # below is deprecated require 'arel/sql/engine' diff --git a/lib/arel/attributes/attribute.rb b/lib/arel/attributes/attribute.rb index b83a32bee7..fdc64d62e0 100644 --- a/lib/arel/attributes/attribute.rb +++ b/lib/arel/attributes/attribute.rb @@ -1,13 +1,16 @@ module Arel module Attributes class Attribute < Struct.new :relation, :name, :column + def eq other + Nodes::Equality.new self, other + end end - class String < Attribute; end - class Time < Attribute; end + class String < Attribute; end + class Time < Attribute; end class Boolean < Attribute; end class Decimal < Attribute; end - class Float < Attribute; end + class Float < Attribute; end class Integer < Attribute; end end end diff --git a/lib/arel/nodes.rb b/lib/arel/nodes.rb new file mode 100644 index 0000000000..855d8cf236 --- /dev/null +++ b/lib/arel/nodes.rb @@ -0,0 +1 @@ +require 'arel/nodes/equality' diff --git a/lib/arel/nodes/equality.rb b/lib/arel/nodes/equality.rb new file mode 100644 index 0000000000..11383b1d89 --- /dev/null +++ b/lib/arel/nodes/equality.rb @@ -0,0 +1,12 @@ +module Arel + module Nodes + class Equality + attr_accessor :left, :right + + def initialize left, right + @left = left + @right = right + end + end + end +end diff --git a/spec/arel/attributes/attribute_spec.rb b/spec/arel/attributes/attribute_spec.rb new file mode 100644 index 0000000000..5599bb7b51 --- /dev/null +++ b/spec/arel/attributes/attribute_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +module Arel + module Attributes + describe 'attribute' do + describe '#eq' do + it 'should return an equality node' do + attribute = Attribute.new nil, nil, nil + equality = attribute.eq 1 + equality.left.should == attribute + equality.right.should == 1 + equality.should be_kind_of Nodes::Equality + end + end + end + end +end |