Sha256: 2ecbae0b2226ec520310225c92b10f0a90110e2db0b0f363616e94b18f480ac7

Contents?: true

Size: 503 Bytes

Versions: 3

Compression:

Stored size: 503 Bytes

Contents

$:.push File.expand_path('../', __FILE__)
require "active_support/all"
require "archiveable/version"

module Archiveable
  extend ActiveSupport::Concern

  included do
    scope :published, -> { where archived_at: nil }
    scope :archived, -> { where.not archived_at: nil }
  end

  def published
    !archived
  end

  def published=(value)
    self.archived = !value
  end

  def archived
    archived_at.present?
  end

  def archived=(value)
    self.archived_at = value ? Time.now : nil
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
archiveable-0.0.3 lib/archiveable.rb
archiveable-0.0.2 lib/archiveable.rb
archiveable-0.0.1 lib/archiveable.rb