Sha256: 5dc6535e43c1411a3c0275dfa3f259029e8764dba10e649f3f4cae2e10c055c2

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-mass-0.1.3 lib/core_ext/object.rb
ruby-mass-0.1.2 lib/core_ext/object.rb
ruby-mass-0.1.1 lib/core_ext/object.rb