class Cequel::Record::HasManyAssociation
Represents a child association declared by {Associations::ClassMethods#has_many has_many}.
@see Associations::ClassMethods#child_associations @since 1.0.0
Attributes
@return [Symbol] name of the child class that this association contains
@return [Boolean] behavior for propagating destruction from parent to
children
@return [Symbol] name of this association
@return [Class] Record
class that declares this association
Public Class Methods
@param owner_class
[Class] Record
class that declares this association @param name [Symbol] name of the association @param options [Options] options for the association @option options [Symbol] :class_name name of the child class @option options [Boolean] :dependent propagation behavior for destroy
@api private
# File lib/cequel/record/has_many_association.rb, line 30 def initialize(owner_class, name, options = {}) options.assert_valid_keys(:class_name, :dependent) @owner_class, @name = owner_class, name @association_class_name = options.fetch(:class_name, name.to_s.classify) case options[:dependent] when :destroy, :delete, nil @dependent = options[:dependent] else fail ArgumentError, "Invalid :dependent option #{options[:dependent].inspect}. " \ "Valid values are :destroy, :delete" end end
Public Instance Methods
@return [Class] class of child association
# File lib/cequel/record/has_many_association.rb, line 49 def association_class @association_class ||= association_class_name.constantize end
@private
# File lib/cequel/record/has_many_association.rb, line 54 def instance_variable_name @instance_variable_name ||= :"@#{name}" end