/
object.rb
40 lines (33 loc) · 1.03 KB
/
object.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class Object
# A convenience method for detaching all class instances with detach
#
def self.detach_all
Mass.index(self.class)[self.class.name].each{|object_id| Mass[object_id].detach}
end
# A convenience method for detaching all class instances with detach!
#
def self.detach_all!
Mass.index(self.class)[self.class.name].each{|object_id| Mass[object_id].detach!}
end
# Mass uses this method to derive object references. Override this method for increasing performance.
# In order to override this method, you would probably want to use <tt>Mass.references</tt> of a sample instance.
#
def _reference_instances(*mods)
Mass.send(:instances_within, *mods)
end
# A convenience method for Mass.references
#
def references(*mods)
Mass.references(self, *mods)
end
# A convenience method for Mass.detach
#
def detach(*mods, &block)
Mass.detach(self, *mods, &block)
end
# A convenience method for Mass.detach!
#
def detach!(*mods, &block)
Mass.detach!(self, *mods, &block)
end
end