Sha256: 105b3bcbe3b6c28856c5fd3c4d9cf7e9dff1ad74b88bab0a77ca4431862e919f

Contents?: true

Size: 1.03 KB

Versions: 12

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
        [self.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

12 entries across 12 versions & 3 rubygems

Version Path
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/arel-7.1.4/lib/arel/nodes/casted.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/arel-7.1.4/lib/arel/nodes/casted.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/arel-7.1.4/lib/arel/nodes/casted.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/arel-7.1.4/lib/arel/nodes/casted.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/arel-7.1.4/lib/arel/nodes/casted.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/arel-7.1.4/lib/arel/nodes/casted.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/arel-7.1.4/lib/arel/nodes/casted.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/arel-7.1.4/lib/arel/nodes/casted.rb
arel-7.1.4 lib/arel/nodes/casted.rb
arel-7.1.3 lib/arel/nodes/casted.rb
arel-7.1.2 lib/arel/nodes/casted.rb
arel-7.1.1 lib/arel/nodes/casted.rb