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:
parent
196b4e05b7
commit
4127484bc1
5 changed files with 37 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
require 'arel/version'
|
||||
require 'arel/table'
|
||||
require 'arel/attributes'
|
||||
require 'arel/nodes'
|
||||
|
||||
# below is deprecated
|
||||
require 'arel/sql/engine'
|
||||
|
|
|
@ -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
1
lib/arel/nodes.rb
Normal file
|
@ -0,0 +1 @@
|
|||
require 'arel/nodes/equality'
|
12
lib/arel/nodes/equality.rb
Normal file
12
lib/arel/nodes/equality.rb
Normal 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
|
17
spec/arel/attributes/attribute_spec.rb
Normal file
17
spec/arel/attributes/attribute_spec.rb
Normal 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
|
Loading…
Reference in a new issue