class MongoModel::Associations::HasManyByIds

Public Instance Methods

define!() click to toggle source
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 8
def define!
  super
  define_dependency_callbacks!
  self
end
define_dependency_callbacks!() click to toggle source
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 14
def define_dependency_callbacks!
  association = self

  if options[:dependent] == :destroy
    owner.before_destroy do
      send(association.name).each { |child| child.destroy }
    end
  elsif options[:dependent] == :delete
    owner.before_destroy do
      send(association.name).delete_all
    end
  end
end
property_name() click to toggle source
# File lib/mongomodel/concerns/associations/has_many_by_ids.rb, line 4
def property_name
  @property_name ||= :"#{singular_name}_ids"
end