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

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) archive!

Change the publish state to true and save the record.



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

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

- (Boolean) archived?

Check to see if this record has been published.

Returns:

  • (Boolean)


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

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

- (Boolean) draft?

Returns:

  • (Boolean)


63
64
65
# File 'lib/gluttonberg/content/publishable.rb', line 63

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

- (Object) publish!

Change the publish state to true and save the record.



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

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

- (Boolean) published?

Check to see if this record has been published.

Returns:

  • (Boolean)


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

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

- (Object) publishing_status



67
68
69
70
71
72
73
# File 'lib/gluttonberg/content/publishable.rb', line 67

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

- (Object) unpublish!

Change the publish state to false and save the record.



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

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