Class: Undestroy::Binding::ActiveRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/undestroy/binding/active_record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, options = {}) ⇒ ActiveRecord

Returns a new instance of ActiveRecord.



6
7
8
9
10
11
12
13
# File 'lib/undestroy/binding/active_record.rb', line 6

def initialize(model, options={})
  ensure_is_ar! model

  self.model = model
  self.config = Undestroy::Config.config.merge(options)

  set_defaults
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



4
5
6
# File 'lib/undestroy/binding/active_record.rb', line 4

def config
  @config
end

#modelObject

Returns the value of attribute model.



4
5
6
# File 'lib/undestroy/binding/active_record.rb', line 4

def model
  @model
end

Instance Method Details

#before_destroy(instance) ⇒ Object



15
16
17
# File 'lib/undestroy/binding/active_record.rb', line 15

def before_destroy(instance)
  config.internals[:archive].new(:config => config, :source => instance).run
end