Parent

Included Modules

Class/Module Index [+]

Quicksearch

Sequel::Model::Associations::AssociationReflection

AssociationReflection is a Hash subclass that keeps information on Sequel::Model associations. It provides methods to reduce internal code duplication. It should not be instantiated by the user.

Public Instance Methods

_add_method() click to toggle source

Name symbol for the _add internal association method

# File lib/sequel/model/associations.rb, line 21
def _add_method
  :"_add_#{singularize(self[:name])}"
end
_dataset_method() click to toggle source

Name symbol for the _dataset association method

# File lib/sequel/model/associations.rb, line 26
def _dataset_method
  :"_#{self[:name]}_dataset"
end
_remove_all_method() click to toggle source

Name symbol for the _remove_all internal association method

# File lib/sequel/model/associations.rb, line 31
def _remove_all_method
  :"_remove_all_#{self[:name]}"
end
_remove_method() click to toggle source

Name symbol for the _remove internal association method

# File lib/sequel/model/associations.rb, line 36
def _remove_method
  :"_remove_#{singularize(self[:name])}"
end
_setter_method() click to toggle source

Name symbol for the _setter association method

# File lib/sequel/model/associations.rb, line 41
def _setter_method
  :"_#{self[:name]}="
end
add_method() click to toggle source

Name symbol for the add association method

# File lib/sequel/model/associations.rb, line 46
def add_method
  :"add_#{singularize(self[:name])}"
end
associated_class() click to toggle source

The class associated to the current model class via this association

# File lib/sequel/model/associations.rb, line 56
def associated_class
  self[:class] ||= constantize(self[:class_name])
end
association_method() click to toggle source

Name symbol for association method, the same as the name of the association.

# File lib/sequel/model/associations.rb, line 51
def association_method
  self[:name]
end
can_have_associated_objects?(obj) click to toggle source

Whether this association can have associated objects, given the current object. Should be false if obj cannot have associated objects because the necessary key columns are NULL.

# File lib/sequel/model/associations.rb, line 63
def can_have_associated_objects?(obj)
  true
end
dataset_helper_method() click to toggle source

Name symbol for the _helper internal association method

# File lib/sequel/model/associations.rb, line 73
def dataset_helper_method
  :"_#{self[:name]}_dataset_helper"
end
dataset_method() click to toggle source

Name symbol for the dataset association method

# File lib/sequel/model/associations.rb, line 68
def dataset_method
  :"#{self[:name]}_dataset"
end
dataset_need_primary_key?() click to toggle source

Whether the dataset needs a primary key to function, true by default.

# File lib/sequel/model/associations.rb, line 78
def dataset_need_primary_key?
  true
end
eager_graph_lazy_dataset?() click to toggle source

Whether to eagerly graph a lazy dataset, true by default. If this is false, the association won’t respect the :eager_graph option when loading the association for a single record.

# File lib/sequel/model/associations.rb, line 91
def eager_graph_lazy_dataset?
  true
end
eager_loading_use_associated_key?() click to toggle source

By default associations do not need to select a key in an associated table to eagerly load.

# File lib/sequel/model/associations.rb, line 84
def eager_loading_use_associated_key?
  false
end
need_associated_primary_key?() click to toggle source

Whether the associated object needs a primary key to be added/removed, false by default.

# File lib/sequel/model/associations.rb, line 97
def need_associated_primary_key?
  false
end
reciprocal() click to toggle source

Returns the reciprocal association variable, if one exists. The reciprocal association is the association in the associated class that is the opposite of the current association. For example, Album.many_to_one :artist and Artist.one_to_many :albums are reciprocal associations. This information is to populate reciprocal associations. For example, when you do this_artist.add_album(album) it sets album.artist to this_artist.

# File lib/sequel/model/associations.rb, line 107
def reciprocal
  return self[:reciprocal] if include?(:reciprocal)
  r_types = Array(reciprocal_type)
  keys = self[:keys]
  associated_class.all_association_reflections.each do |assoc_reflect|
    if r_types.include?(assoc_reflect[:type]) && assoc_reflect[:keys] == keys && assoc_reflect.associated_class == self[:model]
      self[:reciprocal_type] = assoc_reflect[:type]
      return self[:reciprocal] = assoc_reflect[:name]
    end
  end
  self[:reciprocal] = nil
end
reciprocal_array?() click to toggle source

Whether the reciprocal of this association returns an array of objects instead of a single object, true by default.

# File lib/sequel/model/associations.rb, line 122
def reciprocal_array?
  true
end
remove_all_method() click to toggle source

Name symbol for the remove_all_ association method

# File lib/sequel/model/associations.rb, line 127
def remove_all_method
  :"remove_all_#{self[:name]}"
end
remove_method() click to toggle source

Name symbol for the remove_ association method

# File lib/sequel/model/associations.rb, line 132
def remove_method
  :"remove_#{singularize(self[:name])}"
end
remove_should_check_existing?() click to toggle source

Whether to check that an object to be disassociated is already associated to this object, false by default.

# File lib/sequel/model/associations.rb, line 137
def remove_should_check_existing?
  false
end
returns_array?() click to toggle source

Whether this association returns an array of objects instead of a single object, true by default.

# File lib/sequel/model/associations.rb, line 143
def returns_array?
  true
end
select() click to toggle source

The columns to select when loading the association, nil by default.

# File lib/sequel/model/associations.rb, line 148
def select
  self[:select]
end
set_reciprocal_to_self?() click to toggle source

Whether to set the reciprocal association to self when loading associated records, false by default.

# File lib/sequel/model/associations.rb, line 154
def set_reciprocal_to_self?
  false
end
setter_method() click to toggle source

Name symbol for the setter association method

# File lib/sequel/model/associations.rb, line 159
def setter_method
  :"#{self[:name]}="
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.