lib/greygoo/role/container.rb
# Takes the object and gives it to self unconditionally
#
# @param [Object] object The object to take, must be a Containable
Takes the object and gives it to self unconditionally
Takes the object and gives it to self unconditionally
def take(object, collection_name = 'objects', *a)
				oldparent = object.parent
				object.move_to(self, *a)
				sym = "@#{collection_name}".to_sym
				objs(sym) << object
				db_update({}, {'$addToSet' => { collection_name => object.id.to_db }})
				if oldparent
					oldparent.letgo(object, collection_name)
				end
			end
def take ( object , collection_name = 'objects' , * a ) oldparent = object . parent object . move_to ( self , * a ) sym = "@#{collection_name}" . to_sym objs ( sym ) << object db_update ( { } , { '$addToSet' => { collection_name => object . id . to_db } } ) if oldparent oldparent . letgo ( object , collection_name ) end end
Takes the object and gives it to self unconditionally
Takes the object and gives it to self unconditionally
# set the object's parent. this is atomic authoritative # set in our objects # remove from old parent
object
collection_name
a
object The object to take, must be a Containable
object The object to take must be a Containable