Sha256: 6a41219a8f1badbc3c1dceca9b5f05c29b4362b018ac193cc2f035216ce47552

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

class Talkative < ActiveRecord::Base
  has_drafts

  # draft_creation callbacks
  before_save_draft :do_this_before_save
  around_save_draft :do_this_around_save
  after_save_draft :do_this_after_save

  # draft_destruction callbacks
  before_draft_destruction :do_this_before_destruction
  around_draft_destruction :do_this_around_destruction
  after_draft_destruction :do_this_after_destruction

private

  def do_this_before_save
    self.before_comment = 'I changed before save'
  end

  def do_this_around_save
    self.around_early_comment = 'I changed around save (before yield)'
    yield
    self.around_late_comment = 'I changed around save (after yield)'
  end

  def do_this_after_save
    self.after_comment = 'I changed after save'
  end


  def do_this_before_destruction
    self.before_comment = 'I changed before destroy'
  end

  def do_this_around_destruction
    self.around_early_comment = 'I changed around destroy (before yield)'
    yield
    self.around_late_comment = 'I changed around destroy (after yield)'
  end

  def do_this_after_destruction
    self.after_comment = 'I changed after destroy'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
draftsman-0.7.2 spec/dummy/app/models/talkative.rb
draftsman-0.7.1 spec/dummy/app/models/talkative.rb
draftsman-0.7.0 spec/dummy/app/models/talkative.rb
draftsman-0.6.0 spec/dummy/app/models/talkative.rb