1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

adding first node

This commit is contained in:
Aaron Patterson 2010-08-12 15:22:26 -07:00
parent 196b4e05b7
commit 4127484bc1
5 changed files with 37 additions and 3 deletions

View file

@ -1,6 +1,7 @@
require 'arel/version'
require 'arel/table'
require 'arel/attributes'
require 'arel/nodes'
# below is deprecated
require 'arel/sql/engine'

View file

@ -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

1
lib/arel/nodes.rb Normal file
View file

@ -0,0 +1 @@
require 'arel/nodes/equality'

View file

@ -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

View file

@ -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