module Mongoid::Publish

Constants

VERSION

Public Instance Methods

publication_status() click to toggle source
# File lib/mongoid/publish.rb, line 27
def publication_status
  self.published? ? self.published_at : "draft"
end
publish!() click to toggle source
# File lib/mongoid/publish.rb, line 21
def publish!
  self.published    = true
  self.published_at = Time.now
  self.save
end
published?() click to toggle source
# File lib/mongoid/publish.rb, line 16
def published?
  return true if self.published && self.published_at && self.published_at <= Time.now
  false
end

Private Instance Methods

set_published_at() click to toggle source
# File lib/mongoid/publish.rb, line 32
def set_published_at
  self.published_at = Time.now if self.published && self.published_at.nil?
end