associated_object_keys()
click to toggle source
can_have_associated_objects?(obj)
click to toggle source
many_to_one associations can only have associated objects if none of the
:keys options have a nil value.
265: def can_have_associated_objects?(obj)
266: !self[:keys].any?{|k| obj.send(k).nil?}
267: end
dataset_need_primary_key?()
click to toggle source
Whether the dataset needs a primary key to function, false for many_to_one
associations.
270: def dataset_need_primary_key?
271: false
272: end
default_key()
click to toggle source
Default foreign key name symbol for foreign key in current model’s
table that points to the given association’s table’s primary
key.
276: def default_key
277: :"#{self[:name]}_id"
278: end
eager_graph_lazy_dataset?()
click to toggle source
Whether to eagerly graph a lazy dataset, true for many_to_one associations
only if the key is nil.
282: def eager_graph_lazy_dataset?
283: self[:key].nil?
284: end
eager_limit_strategy()
click to toggle source
many_to_one associations don’t need an eager limit strategy
287: def eager_limit_strategy
288: nil
289: end
eager_loader_key()
click to toggle source
The key to use for the key hash when eager loading
292: def eager_loader_key
293: cached_fetch(:eager_loader_key){self[:key]}
294: end
primary_key()
click to toggle source
The column(s) in the associated table that the key in the current table
references (either a symbol or an array).
297: def primary_key
298: cached_fetch(:primary_key){associated_class.primary_key}
299: end
primary_key_method()
click to toggle source
The method symbol or array of method symbols to call on the associated
object to get the value to use for the foreign keys.
309: def primary_key_method
310: cached_fetch(:primary_key_method){primary_key}
311: end
primary_key_methods()
click to toggle source
The array of method symbols to call on the associated object to get the
value to use for the foreign keys.
315: def primary_key_methods
316: cached_fetch(:primary_key_methods){Array(primary_key_method)}
317: end
primary_keys()
click to toggle source
The columns in the associated table that the key in the current table
references (always an array).
302: def primary_keys
303: cached_fetch(:primary_keys){Array(primary_key)}
304: end
qualified_primary_key()
click to toggle source
primary_key
qualified by the associated table
320: def qualified_primary_key
321: cached_fetch(:qualified_primary_key){self[:qualify] == false ? primary_key : qualify_assoc(primary_key)}
322: end
reciprocal_array?()
click to toggle source
True only if the reciprocal is a one_to_many association.
325: def reciprocal_array?
326: !set_reciprocal_to_self?
327: end
returns_array?()
click to toggle source
Whether this association returns an array of objects instead of a single
object, false for a many_to_one association.
331: def returns_array?
332: false
333: end
set_reciprocal_to_self?()
click to toggle source
True only if the reciprocal is a one_to_one association.
336: def set_reciprocal_to_self?
337: reciprocal
338: reciprocal_type == :one_to_one
339: end