Class: ActiveRecord::Relation::QueryAttribute

Inherits:
ActiveModel::Attribute show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/relation/query_attribute.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from ActiveModel::Attribute

#name, #type, #value_before_type_cast

Instance Method Summary collapse

Methods inherited from ActiveModel::Attribute

#==, #came_from_user?, #changed?, #changed_in_place?, #encode_with, #forgetting_assignment, from_database, from_user, #has_been_read?, #hash, #init_with, #initialize, #initialized?, null, #original_value, #original_value_for_database, #serializable?, uninitialized, #value, with_cast_value, #with_type, #with_value_from_database, #with_value_from_user

Constructor Details

This class inherits a constructor from ActiveModel::Attribute

Instance Method Details

#infinite?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/relation/query_attribute.rb', line 27

def infinite?
  infinity?(value_before_type_cast) || serializable? && infinity?(value_for_database)
end

#nil?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/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) && serializable? && value_for_database.nil?
  end
end

#type_cast(value) ⇒ Object



8
9
10
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/relation/query_attribute.rb', line 8

def type_cast(value)
  value
end

#unboundable?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/relation/query_attribute.rb', line 31

def unboundable?
  unless defined?(@_unboundable)
    serializable? { |value| @_unboundable = value <=> 0 } && @_unboundable = nil
  end
  @_unboundable
end

#value_for_databaseObject



12
13
14
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/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/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/relation/query_attribute.rb', line 16

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