diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-06-01 12:22:00 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-06-01 12:22:00 -0300 |
commit | 7442623100f5ecdd73fd8f68376431762380f4e5 (patch) | |
tree | 41301b2a4805e2b9a7cb4f35760ed0fce8f25fb3 | |
parent | c7ca1568013d244b9c61147b20b4424d741e91ac (diff) | |
parent | 0d69486b7c4ab347133847589da282945b8b85c6 (diff) | |
download | rails-7442623100f5ecdd73fd8f68376431762380f4e5.tar.gz rails-7442623100f5ecdd73fd8f68376431762380f4e5.tar.bz2 rails-7442623100f5ecdd73fd8f68376431762380f4e5.zip |
Merge pull request #367 from vipulnsward/move-cased
Move casted to its own file
-rw-r--r-- | lib/arel/nodes.rb | 41 | ||||
-rw-r--r-- | lib/arel/nodes/casted.rb | 40 |
2 files changed, 41 insertions, 40 deletions
diff --git a/lib/arel/nodes.rb b/lib/arel/nodes.rb index 7d900fe710..8d61bb320f 100644 --- a/lib/arel/nodes.rb +++ b/lib/arel/nodes.rb @@ -55,43 +55,4 @@ require 'arel/nodes/string_join' require 'arel/nodes/sql_literal' -module Arel - module Nodes - class Casted < Arel::Nodes::Node # :nodoc: - attr_reader :val, :attribute - def initialize val, attribute - @val = val - @attribute = attribute - super() - end - - def nil?; @val.nil?; end - - def eql? other - self.class == other.class && - self.val == other.val && - self.attribute == other.attribute - end - alias :== :eql? - end - - class Quoted < Arel::Nodes::Unary # :nodoc: - alias :val :value - def nil?; val.nil?; end - end - - def self.build_quoted other, attribute = nil - case other - when Arel::Nodes::Node, Arel::Attributes::Attribute, Arel::Table, Arel::Nodes::BindParam, Arel::SelectManager, Arel::Nodes::Quoted - other - else - case attribute - when Arel::Attributes::Attribute - Casted.new other, attribute - else - Quoted.new other - end - end - end - end -end +require 'arel/nodes/casted' diff --git a/lib/arel/nodes/casted.rb b/lib/arel/nodes/casted.rb new file mode 100644 index 0000000000..9fa02955ef --- /dev/null +++ b/lib/arel/nodes/casted.rb @@ -0,0 +1,40 @@ +module Arel + module Nodes + class Casted < Arel::Nodes::Node # :nodoc: + attr_reader :val, :attribute + def initialize val, attribute + @val = val + @attribute = attribute + super() + end + + def nil?; @val.nil?; end + + def eql? other + self.class == other.class && + self.val == other.val && + self.attribute == other.attribute + end + alias :== :eql? + end + + class Quoted < Arel::Nodes::Unary # :nodoc: + alias :val :value + def nil?; val.nil?; end + end + + def self.build_quoted other, attribute = nil + case other + when Arel::Nodes::Node, Arel::Attributes::Attribute, Arel::Table, Arel::Nodes::BindParam, Arel::SelectManager, Arel::Nodes::Quoted + other + else + case attribute + when Arel::Attributes::Attribute + Casted.new other, attribute + else + Quoted.new other + end + end + end + end +end |