Class: Rod::ReferenceUpdater

Inherits:
Object
  • Object
show all
Defined in:
lib/rod/reference_updater.rb

Overview

This class provides the set of reference updaters, that is objects used to break down the process of data storage into separate steps. If there is an object A which reference object B, there might be two cases: object A is stored before object B is stored or after the object B is stored. In the first case, the id of the object B is not know, so it might be updated only after the object is stored. If the object B stored the reference to object A (to update its reference to the object B), then the object A could not be GC’ed until object B is stored. For large nets of objects, this would result in large non-GCable collections of objects. The reference updater splits the reference of object B to A and allows for GC of A, even thou B is not yet stored.

Defined Under Namespace

Classes: IndexUpdater, PluralUpdater, SingularUpdater

Class Method Summary collapse

Class Method Details

.for_index(index) ⇒ Object

Creates reference updater for an index. It is used when the indexed plural association includes objects that are not yet persisted.



81
82
83
# File 'lib/rod/reference_updater.rb', line 81

def self.for_index(index)
  IndexUpdater.new(index)
end

.for_plural(collection, index, database) ⇒ Object

Creates plural reference updater for given collection proxy with given index.



74
75
76
# File 'lib/rod/reference_updater.rb', line 74

def self.for_plural(collection,index,database)
  PluralUpdater.new(database,collection,index)
end

.for_singular(object, property, database) ⇒ Object

Creates singular reference updater of for the property of the object that belongs to the database.



68
69
70
# File 'lib/rod/reference_updater.rb', line 68

def self.for_singular(object,property,database)
  SingularUpdater.new(database,object.rod_id,object.class.name_hash,property)
end