Class: ActiveRecord::Relation::QueryAttribute

Inherits:
ActiveModel::Attribute
  • Object
show all
Defined in:
lib/active_record/relation/query_attribute.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#infinite?Boolean

Returns:

  • (Boolean)


28
29
30
31
# File 'lib/active_record/relation/query_attribute.rb', line 28

def infinite?
  infinity?(value_before_type_cast) || infinity?(value_for_database)
rescue ::RangeError
end

#nil?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
# File 'lib/active_record/relation/query_attribute.rb', line 20

def nil?
  unless value_before_type_cast.is_a?(StatementCache::Substitute)
    value_before_type_cast.nil? ||
      type.respond_to?(:subtype, true) && value_for_database.nil?
  end
rescue ::RangeError
end

#type_cast(value) ⇒ Object



8
9
10
# File 'lib/active_record/relation/query_attribute.rb', line 8

def type_cast(value)
  value
end

#unboundable?Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
40
41
42
# File 'lib/active_record/relation/query_attribute.rb', line 33

def unboundable?
  if defined?(@_unboundable)
    @_unboundable
  else
    value_for_database unless value_before_type_cast.is_a?(StatementCache::Substitute)
    @_unboundable = nil
  end
rescue ::RangeError
  @_unboundable = type.cast(value_before_type_cast) <=> 0
end

#value_for_databaseObject



12
13
14
# File 'lib/active_record/relation/query_attribute.rb', line 12

def value_for_database
  @value_for_database ||= super
end

#with_cast_value(value) ⇒ Object



16
17
18
# File 'lib/active_record/relation/query_attribute.rb', line 16

def with_cast_value(value)
  QueryAttribute.new(name, value, type)
end