123456789_123456789_123456789_123456789_123456789_

Class: Arel::Nodes::Casted

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Arel::Nodes::NodeExpression
Defined in: activerecord/lib/arel/nodes/casted.rb

Class Method Summary

Instance Attribute Summary

Node - Inherited

Instance Method Summary

Constructor Details

.new(value, attribute) ⇒ Casted

[ GitHub ]

  
# File 'activerecord/lib/arel/nodes/casted.rb', line 9

def initialize(value, attribute)
  @value     = value
  @attribute = attribute
  super()
end

Instance Attribute Details

#attribute (readonly)

[ GitHub ]

  
# File 'activerecord/lib/arel/nodes/casted.rb', line 6

attr_reader :value, :attribute

#nil?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/arel/nodes/casted.rb', line 15

def nil?; value.nil?; end

#value (readonly) Also known as: #value_before_type_cast

[ GitHub ]

  
# File 'activerecord/lib/arel/nodes/casted.rb', line 6

attr_reader :value, :attribute

#value_before_type_cast (readonly)

Alias for #value.

[ GitHub ]

  
# File 'activerecord/lib/arel/nodes/casted.rb', line 7

alias :value_before_type_cast :value

Instance Method Details

#==(other)

Alias for #eql?.

[ GitHub ]

  
# File 'activerecord/lib/arel/nodes/casted.rb', line 34

alias :== :eql?

#eql?(other) ⇒ Boolean Also known as: #==

[ GitHub ]

  
# File 'activerecord/lib/arel/nodes/casted.rb', line 29

def eql?(other)
  self.class == other.class &&
    self.value == other.value &&
    self.attribute == other.attribute
end

#hash

[ GitHub ]

  
# File 'activerecord/lib/arel/nodes/casted.rb', line 25

def hash
  [self.class, value, attribute].hash
end

#value_for_database

[ GitHub ]

  
# File 'activerecord/lib/arel/nodes/casted.rb', line 17

def value_for_database
  if attribute.able_to_type_cast?
    attribute.type_cast_for_database(value)
  else
    value
  end
end