Sha256: 6e80efa46838754f7d966f05b29f9cc779cf58315fb270d7a396ea5acdfeb5c1

Contents?: true

Size: 1.08 KB

Versions: 23

Compression:

Stored size: 1.08 KB

Contents

module Cms
  module Behaviors
    module Archiving
      def self.included(model_class)
        model_class.extend(MacroMethods)
      end
      module MacroMethods
        def archivable?
          !!@is_archivable
        end
        def is_archivable(options={})
          @is_archivable = true
          include InstanceMethods

          scope :archived, :conditions => {:archived => true}
          scope :not_archived, :conditions => {:archived => false}        
        end
      end
      module InstanceMethods
        def archive
          self.archived = true
          self.version_comment = "Archived"
          self.save
        end
        def archive!
          self.archived = true
          self.version_comment = "Archived"          
          self.save!
        end
        def unarchive
          self.archived = false
          self.version_comment = "Unarchived"          
          self.save
        end
        def unarchive!
          self.archived = false
          self.version_comment = "Unarchived"          
          self.save!
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
browsercms-3.5.7 lib/cms/behaviors/archiving.rb
browsercms-3.5.6 lib/cms/behaviors/archiving.rb
browsercms-3.5.5 lib/cms/behaviors/archiving.rb
browsercms-3.5.4 lib/cms/behaviors/archiving.rb
browsercms-3.5.3 lib/cms/behaviors/archiving.rb
browsercms-3.5.2 lib/cms/behaviors/archiving.rb
browsercms-3.5.1 lib/cms/behaviors/archiving.rb
browsercms-3.5.0 lib/cms/behaviors/archiving.rb
browsercms-3.5.0.rc3 lib/cms/behaviors/archiving.rb
browsercms-3.5.0.rc2 lib/cms/behaviors/archiving.rb
browsercms-3.5.0.rc1 lib/cms/behaviors/archiving.rb
browsercms-3.4.2 lib/cms/behaviors/archiving.rb
browsercms-3.3.4 lib/cms/behaviors/archiving.rb
browsercms-3.4.2.rc1 lib/cms/behaviors/archiving.rb
browsercms-3.4.1 lib/cms/behaviors/archiving.rb
browsercms-3.4.0 lib/cms/behaviors/archiving.rb
browsercms-3.4.0.rc2 lib/cms/behaviors/archiving.rb
browsercms-3.4.0.rc1 lib/cms/behaviors/archiving.rb
browsercms-3.3.3 lib/cms/behaviors/archiving.rb
browsercms-3.3.2 lib/cms/behaviors/archiving.rb