Module: Cms::Behaviors::Publishing::InstanceMethods
- Defined in:
- lib/cms/behaviors/publishing.rb
Instance Method Summary collapse
- #live? ⇒ Boolean
- #publish ⇒ Object
- #publish! ⇒ Object
- #publish_by_page(page) ⇒ Object
- #publish_by_page!(page) ⇒ Object
- #publishable? ⇒ Boolean
- #set_published ⇒ Object
- #status ⇒ Object
- #status_name ⇒ Object
Instance Method Details
#live? ⇒ Boolean
78 79 80 |
# File 'lib/cms/behaviors/publishing.rb', line 78 def live? self.class.versioned? ? versions.count(:conditions => ['version > ? AND published = ?', version, true]) == 0 && published? : true end |
#publish ⇒ Object
40 41 42 43 44 |
# File 'lib/cms/behaviors/publishing.rb', line 40 def publish self.publish_on_save = true self.version_comment = "Published" if self.class.versioned? save end |
#publish! ⇒ Object
45 46 47 48 49 |
# File 'lib/cms/behaviors/publishing.rb', line 45 def publish! self.publish_on_save = true self.version_comment = "Published" if self.class.versioned? save! end |
#publish_by_page(page) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/cms/behaviors/publishing.rb', line 50 def publish_by_page(page) self.published_by_page = page if publish self.published_by_page = nil true else false end end |
#publish_by_page!(page) ⇒ Object
59 60 61 62 63 |
# File 'lib/cms/behaviors/publishing.rb', line 59 def publish_by_page!(page) self.published_by_page = page publish! self.published_by_page = nil end |
#publishable? ⇒ Boolean
33 34 35 36 37 38 39 |
# File 'lib/cms/behaviors/publishing.rb', line 33 def publishable? if self.class.connectable? new_record? ? connect_to_page_id.blank? : connected_page_count < 1 else true end end |
#set_published ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/cms/behaviors/publishing.rb', line 64 def set_published self.published = !!@publish_on_save if self.published && self.respond_to?(:published_at) && !self.published_at self.published_at = Time.now end @publish_on_save = nil true end |
#status ⇒ Object
72 73 74 |
# File 'lib/cms/behaviors/publishing.rb', line 72 def status published? ? :published : :draft end |
#status_name ⇒ Object
75 76 77 |
# File 'lib/cms/behaviors/publishing.rb', line 75 def status_name status.to_s.titleize end |