123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::Reflection::HasOneReflection

Do not use. This class is for internal use only.

Constant Summary

AssociationReflection - Inherited

FROZEN_EMPTY_ARRAY

Class Method Summary

Instance Attribute Summary

AssociationReflection - Inherited

#belongs_to?

Returns true if self is a belongs_to reflection.

#collection?

Returns whether or not this association reflection is for a collection association.

#deprecated?, #extensions, #foreign_type, #has_inverse?,
#has_one?

Returns true if self is a has_one reflection.

#has_scope?, #nested?,
#parent_reflection
#polymorphic?, #type,
#validate?

Returns whether or not the association should be validated as part of the parent's validation.

MacroReflection - Inherited

#active_record, #autosave=,
#name

Returns the name of the macro.

#options

Returns the hash of options used for the macro.

#scope, #plural_name

AbstractReflection - Inherited

#counter_must_be_updated_by_has_many?,
#has_active_cached_counter?

Returns whether this association has a counter cache and its column values were backfilled (and so it is used internally by methods like size/+any?+/etc).

#has_cached_counter?

Returns whether this association has a counter cache.

#inverse_updates_counter_cache?
#inverse_updates_counter_in_memory?, #strict_loading?, #through_reflection?

Instance Method Summary

AssociationReflection - Inherited

#active_record_primary_key,
#active_record_primary_key_definition

Same as active_record_primary_key but returns an ::ActiveRecord::Key.

#add_as_polymorphic_through, #add_as_source, #add_as_through, #association_class, #association_foreign_key,
#association_foreign_key_definition

Same as association_foreign_key but returns an ::ActiveRecord::Key.

#association_primary_key,
#association_primary_key_definition

Same as association_primary_key but returns an ::ActiveRecord::Key.

#association_route, #association_route_chain, #check_eager_loadable!, #check_validity!,
#clear_association_scope_cache

Pass the concrete target class for polymorphic associations.

#collect_join_chain

A chain of reflections from this one back to the owner.

#compute_class, #foreign_key,
#foreign_key_definition

Same as foreign_key but returns an ::ActiveRecord::Key.

#freeze, #join_table,
#macro

Returns the macro type.

#polymorphic_inverse_of, #polymorphic_name,
#prepare_default_association_route

Resolves the default route ahead of the reflection being made shareable, so that every Ractor can read it from the frozen slot.

#source_reflection, #through_reflection, #association_route_cache, #association_route_class, #association_route_constraints, #association_route_target_key,
#automatic_inverse_of

returns either nil or the inverse association name that it finds.

#build_association_route,
#can_find_inverse_of_automatically?

Checks to see if the reflection doesn't have any options that prevent us from being able to guess the inverse automatically.

#current_default_association_route?

Compares loaded contexts by identity: a context matching the slot's was loaded when the slot was filled, so this needn't load anything.

#default_association_route

Slots contain [origin context, destination class, destination context, route].

#default_destination_class, #derive_class_name, #derive_fk_query_constraints, #derive_foreign_key, #derive_join_table, #initialize_copy,
#inverse_name

Attempts to find the inverse association name automatically.

#resolve_association_route,
#scope_allows_automatic_inverse_of?

Scopes on the potential inverse reflection prevent automatic inverse_of, since the scope could exclude the owner record we would inverse from.

#valid_inverse_reflection?

Checks if the inverse reflection that is returned from the automatic_inverse_of method is a valid reflection.

MacroReflection - Inherited

#==

Returns true if self and other_aggregation have the same name attribute, active_record attribute, and other_aggregation has an options hash assigned to it.

#compute_class,
#klass

Returns the class for the macro.

#scope_for, #derive_class_name, #normalize_options, #_klass

AbstractReflection - Inherited

#alias_candidate, #association_route_for_join, #association_scope_cache,
#build_association

Returns a new, unsaved instance of the associated class.

#build_scope, #chain, #check_validity_of_inverse!,
#class_name

Returns the class name for the macro.

#constraints, #counter_cache_column, #inverse_of,
#inverse_which_updates_counter_cache

We need to avoid the following situation:

#join_scope, #join_scopes, #klass_join_scope,
#scopes

Returns a list of scopes that should be applied for this ::ActiveRecord::Reflection object when querying the database.

#strict_loading_violation_message, #table_name,
#actual_source_reflection

FIXME: this is a horrible name.

#ensure_option_not_given_as_class!,
#inferred_primary_key_definition

The Key form of a model's inferred primary key.

#primary_key, #primary_key_definition

Constructor Details

This class inherits a constructor from ActiveRecord::Reflection::AssociationReflection

Instance Attribute Details

#has_one? ⇒ Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1072

def has_one?; true; end

Instance Method Details

#association_class

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1074

def association_class
  if options[:through]
    Associations::HasOneThroughAssociation
  else
    Associations::HasOneAssociation
  end
end

#macro

[ GitHub ]

  
# File 'activerecord/lib/active_record/reflection.rb', line 1070

def macro; :has_one; end