Sha256: 9a951e6b4d772fedd853c4b4bc0ba80b583d56252d296512d9ed58e3a8f39f09

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

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 hash
         [@class, @val, @attribute].hash
      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

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
abaci-0.3.0 vendor/bundle/gems/arel-7.1.0/lib/arel/nodes/casted.rb
arel-7.1.0 lib/arel/nodes/casted.rb