ryanlowe / acts_as_indestructible

Mark objects as destroyed instead of deleting them from the database for Ruby on Rails ActiveRecord

This URL has Read+Write access

ryanlowe (author)
Mon May 26 10:28:05 -0700 2008
commit  d52934826729610344157da828f87c8a6cfa4e79
tree    b57ec89e0e220f34e27ca6ffbe74463cff357a87
parent  62743939b85922e7ce478a904368f6af5e0f3d1b
acts_as_indestructible / lib / fixture.rb
100644 17 lines (15 sloc) 0.507 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Fixture
  
  #TODO: this is fragile
  def find
    klass = @class_name.is_a?(Class) ? @class_name : Object.const_get(@class_name) rescue nil
    if klass
      if klass.respond_to? :destroyed_condition
        klass.find(self[klass.primary_key], :include_destroyed => true)
      else # bad workaround! before the framework is loaded
        klass.find(self[klass.primary_key])
      end
    else
      raise FixtureClassNotFound, "The class #{@class_name.inspect} was not found."
    end
  end
  
end