Class: Content
- Defined in:
- app/models/content.rb
Defined Under Namespace
Classes: Version
Instance Attribute Summary collapse
-
#draft ⇒ Object
Returns the value of attribute draft.
Class Method Summary collapse
Instance Method Summary collapse
- #author_id=(author_id) ⇒ Object
- #category_titles ⇒ Object
- #diff_against_version(version) ⇒ Object
- #draft? ⇒ Boolean
- #just_published? ⇒ Boolean
- #owner ⇒ Object
- #owners ⇒ Object
- #pending? ⇒ Boolean
- #published? ⇒ Boolean
- #published_at=(published_at) ⇒ Object
- #published_at?(date) ⇒ Boolean
- #published_month ⇒ Object
- #published_year ⇒ Object
- #state ⇒ Object
- #to_param ⇒ Object
Instance Attribute Details
#draft ⇒ Object
Returns the value of attribute draft.
79 80 81 |
# File 'app/models/content.rb', line 79 def draft @draft end |
Class Method Details
.primary ⇒ Object
58 59 60 |
# File 'app/models/content.rb', line 58 def primary published.first end |
Instance Method Details
#author_id=(author_id) ⇒ Object
84 85 86 87 |
# File 'app/models/content.rb', line 84 def () # FIXME this is only needed because belongs_to_cacheable can't be non-polymorphic, yet self. = User.find() if end |
#category_titles ⇒ Object
75 76 77 |
# File 'app/models/content.rb', line 75 def category_titles categories.collect(&:title) end |
#diff_against_version(version) ⇒ Object
121 122 123 124 125 |
# File 'app/models/content.rb', line 121 def diff_against_version(version) # return '(orginal version)' if version == versions.earliest.version version = versions[version] HtmlDiff.diff(version.excerpt_html + version.body_html, excerpt_html + body_html) end |
#draft? ⇒ Boolean
97 98 99 |
# File 'app/models/content.rb', line 97 def draft? published_at.nil? end |
#just_published? ⇒ Boolean
117 118 119 |
# File 'app/models/content.rb', line 117 def just_published? published? && published_at_changed? end |
#owner ⇒ Object
71 72 73 |
# File 'app/models/content.rb', line 71 def owner section end |
#owners ⇒ Object
67 68 69 |
# File 'app/models/content.rb', line 67 def owners owner.owners << owner end |
#pending? ⇒ Boolean
101 102 103 |
# File 'app/models/content.rb', line 101 def pending? !published? end |
#published? ⇒ Boolean
105 106 107 |
# File 'app/models/content.rb', line 105 def published? !published_at.nil? && published_at <= Time.zone.now end |
#published_at=(published_at) ⇒ Object
80 81 82 |
# File 'app/models/content.rb', line 80 def published_at=(published_at) write_attribute(:published_at, draft.to_i == 1 ? nil : published_at) end |
#published_at?(date) ⇒ Boolean
109 110 111 |
# File 'app/models/content.rb', line 109 def published_at?(date) published? && date == [:year, :month, :day].map { |key| published_at.send(key).to_s } end |
#published_month ⇒ Object
93 94 95 |
# File 'app/models/content.rb', line 93 def published_month Time.local(published_at.year, published_at.month, 1) end |
#published_year ⇒ Object
89 90 91 |
# File 'app/models/content.rb', line 89 def published_year Time.local(published_at.year, 1, 1) end |
#state ⇒ Object
113 114 115 |
# File 'app/models/content.rb', line 113 def state pending? ? :pending : :published end |
#to_param ⇒ Object
63 64 65 |
# File 'app/models/content.rb', line 63 def to_param permalink end |