Sha256: 443327f98aa4b89239e720be2ffb5f5c57dd74ef8d8a7678e1c9b986e586caf2

Contents?: true

Size: 864 Bytes

Versions: 3

Compression:

Stored size: 864 Bytes

Contents

class Guide < ActiveRecord::Base
  acts_as_edition :edition_chain => [:abbreviation, :imprint, :places],
                  :resources => [:country, :retailers, :authors],
                  :pre_hook => :unpublish_self,
                  :after_clone => :increment_descendant_year,
                  :post_hook => :publish_descendant,
                  :conditions => { :returns_true => true }
  has_one :abbreviation
  belongs_to :imprint
  has_many :places
  has_one :country
  has_many :retailers
  has_and_belongs_to_many :authors

protected

  def unpublish_self
    self.published = false
    self.save!
  end

  def increment_descendant_year
    self.year = (self.year.to_i + 1).to_s
    self.save!
  end

  def publish_descendant
    self.descendant.published = true
    self.descendant.save!
  end

  def returns_true
    name != 'Noclonelandia'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
acts_as_edition-1.0.2 test/fixtures/guide.rb
acts_as_edition-1.0.1 test/fixtures/guide.rb
acts_as_edition-1.0.0 test/fixtures/guide.rb