Sha256: c1509722a5fd3eabc86c1c34504d9a6257deaa33cacdf08dd2f6a70e699c5793

Contents?: true

Size: 1.09 KB

Versions: 33

Compression:

Stored size: 1.09 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

          named_scope :archived, :conditions => {:archived => true}
          named_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

33 entries across 33 versions & 11 rubygems

Version Path
SFEley-browsercms-3.0.2 lib/cms/behaviors/archiving.rb
buzzware-browsercms-3.0.2 lib/cms/behaviors/archiving.rb
coredumplings-browsercms-3.0.0 lib/cms/behaviors/archiving.rb
nate-browsercms-3.0.210 lib/cms/behaviors/archiving.rb
nate-browsercms-3.0.211 lib/cms/behaviors/archiving.rb
we5-browsercms-3.0.1.1 lib/cms/behaviors/archiving.rb
webficient-browsercms-3.0.1 lib/cms/behaviors/archiving.rb
webficient-browsercms-3.0.2 lib/cms/behaviors/archiving.rb
webficient-browsercms-3.0.3 lib/cms/behaviors/archiving.rb
webficient-browsercms-3.0.4 lib/cms/behaviors/archiving.rb
browsercms-3.1.5 lib/cms/behaviors/archiving.rb
browsercms-3.1.4 lib/cms/behaviors/archiving.rb
browsercms-3.1.3 lib/cms/behaviors/archiving.rb
bf4-browsercms-3.1.0 lib/cms/behaviors/archiving.rb
drujensen-browsercms-3.2.0 lib/cms/behaviors/archiving.rb
browsercms-3.1.2 lib/cms/behaviors/archiving.rb
browsercms-3.1.1 lib/cms/behaviors/archiving.rb
browsercmsi-3.1.0 lib/cms/behaviors/archiving.rb
browsercms-3.1.0 lib/cms/behaviors/archiving.rb
we5-browsercms-3.1.0 lib/cms/behaviors/archiving.rb