aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/nodes
diff options
context:
space:
mode:
authorErnie Miller <ernie@metautonomo.us>2011-03-09 02:27:43 +0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-03-09 03:03:05 +0800
commit21e052796d3007488d5dd9f00299a3a22fdb6249 (patch)
tree10807b13b1af103dc961eeed5ce1a6ee73cde357 /lib/arel/nodes
parent2fc53bec29bb660e501cf350ae07506082dcb110 (diff)
downloadrails-21e052796d3007488d5dd9f00299a3a22fdb6249.tar.gz
rails-21e052796d3007488d5dd9f00299a3a22fdb6249.tar.bz2
rails-21e052796d3007488d5dd9f00299a3a22fdb6249.zip
Replace MathOperation with InfixOperation to support more operators
Diffstat (limited to 'lib/arel/nodes')
-rw-r--r--lib/arel/nodes/infix_operation.rb42
-rw-r--r--lib/arel/nodes/math_operation.rb15
2 files changed, 42 insertions, 15 deletions
diff --git a/lib/arel/nodes/infix_operation.rb b/lib/arel/nodes/infix_operation.rb
new file mode 100644
index 0000000000..6847650fe4
--- /dev/null
+++ b/lib/arel/nodes/infix_operation.rb
@@ -0,0 +1,42 @@
+module Arel
+ module Nodes
+
+ class InfixOperation < Binary
+ include Arel::Expressions
+ include Arel::Predications
+ include Arel::Math
+
+ attr_reader :operator
+
+ def initialize operator, left, right
+ super(left, right)
+ @operator = operator
+ end
+ end
+
+ class Multiplication < InfixOperation
+ def initialize left, right
+ super(:*, left, right)
+ end
+ end
+
+ class Division < InfixOperation
+ def initialize left, right
+ super(:/, left, right)
+ end
+ end
+
+ class Addition < InfixOperation
+ def initialize left, right
+ super(:+, left, right)
+ end
+ end
+
+ class Subtraction < InfixOperation
+ def initialize left, right
+ super(:-, left, right)
+ end
+ end
+
+ end
+end \ No newline at end of file
diff --git a/lib/arel/nodes/math_operation.rb b/lib/arel/nodes/math_operation.rb
deleted file mode 100644
index d9820f1ece..0000000000
--- a/lib/arel/nodes/math_operation.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module Arel
- module Nodes
- class MathOperation < Binary
- include Arel::Expressions
- include Arel::Predications
- include Arel::Math
- end
-
- class Multiplication < MathOperation; end
- class Division < MathOperation; end
- class Addition < MathOperation; end
- class Subtraction < MathOperation; end
-
- end
-end \ No newline at end of file