Module: Gluttonberg::Content::Publishable::InstanceMethods

Defined in:
lib/gluttonberg/content/publishable.rb

Instance Method Summary collapse

Instance Method Details

#archive!Object

Change the publish state to true and save the record.



55
56
57
# File 'lib/gluttonberg/content/publishable.rb', line 55

def archive!
  update_attributes(:state=>"archived")
end

#archived?Boolean

Check to see if this record has been published.

Returns:

  • (Boolean)


65
66
67
# File 'lib/gluttonberg/content/publishable.rb', line 65

def archived?
  self.state == "archived"
end

#clean_published_dateObject



81
82
83
84
85
# File 'lib/gluttonberg/content/publishable.rb', line 81

def clean_published_date
  if self.state != "published"
    self.published_at = nil
  end  
end

#draft?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/gluttonberg/content/publishable.rb', line 69

def draft?
  self.state == "draft" || self.state == "ready" || self.state == "not_ready"
end

#publish!Object

Change the publish state to true and save the record.



40
41
42
# File 'lib/gluttonberg/content/publishable.rb', line 40

def publish!
  update_attributes(:state=>"published")
end

#published?Boolean

Check to see if this record has been published.

Returns:

  • (Boolean)


60
61
62
# File 'lib/gluttonberg/content/publishable.rb', line 60

def published?
  self.state == "published" && published_at <= Time.zone.now
end

#publishing_statusObject



73
74
75
76
77
78
79
# File 'lib/gluttonberg/content/publishable.rb', line 73

def publishing_status
  if draft?
    "Draft"
  else  
    self.state.capitalize unless self.state.blank?
  end  
end

#unpublishObject

Change the publish state to draft but not save the record



50
51
52
# File 'lib/gluttonberg/content/publishable.rb', line 50

def unpublish
  assign_attributes(:state=>"draft")
end

#unpublish!Object

Change the publish state to false and save the record.



45
46
47
# File 'lib/gluttonberg/content/publishable.rb', line 45

def unpublish!
  update_attributes(:state=>"draft")
end