Module: OrganizzePermanentRecords
- Defined in:
- lib/organizze_permanent_records.rb,
lib/organizze_permanent_records/version.rb
Defined Under Namespace
Modules: EarlyRails, InstanceMethods, Rails2, Scopes
Constant Summary collapse
- VERSION =
"0.0.9"
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
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 |
# File 'lib/organizze_permanent_records.rb', line 4 def self.included(base) base.send :include, InstanceMethods # Rails 3 if ActiveRecord::VERSION::MAJOR >= 3 base.extend Scopes base.instance_eval { define_model_callbacks :revive } # Rails 2.x.x elsif base.respond_to?(:named_scope) base.named_scope :deleted, :conditions => 'deleted_at IS NOT NULL' base.named_scope :not_deleted, :conditions => { :deleted_at => nil } base.instance_eval { define_callbacks :before_revive, :after_revive } base.send :alias_method_chain, :destroy, :permanent_records base.extend Rails2 # Early Rails code else base.extend EarlyRails base.instance_eval { define_callbacks :before_revive, :after_revive } end base.instance_eval do before_revive :revive_destroyed_dependent_records def is_permanent? columns.detect {|c| 'deleted_at' == c.name} end end end |