Module: Transit::Package::Post
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/transit/package/post.rb
Defined Under Namespace
Modules: Validations
Instance Method Summary collapse
-
#next_post ⇒ Object
Grab the post “next” to this one, ordered by post date.
-
#previous_post ⇒ Object
Grab the post “previous” to this one, ordered by post date.
-
#teaser ⇒ Object
The “teaser” is a shortened version of a post used to display on “index” pages.
-
#timestamp ⇒ Object
Returns a timestamp formatted to a normal “post date”.
Instance Method Details
#next_post ⇒ Object
Grab the post “next” to this one, ordered by post date
45 46 47 |
# File 'lib/transit/package/post.rb', line 45 def next_post @next_post ||= self.class.only(:title, :slug).where(:post_date.gt => self.post_date).ascending(:post_date).first end |
#previous_post ⇒ Object
Grab the post “previous” to this one, ordered by post date
37 38 39 |
# File 'lib/transit/package/post.rb', line 37 def previous_post @previous_post ||= self.class.only(:title, :slug).where(:post_date.lt => self.post_date).descending(:post_date).first end |
#teaser ⇒ Object
The “teaser” is a shortened version of a post used to display on “index” pages. Post models include a “teaser” and a “default teaser” allowing teasers to be automatically generated from the first paragraph of the html body. It is assumed that all posts will include at least one Text context containing the body of the post
61 62 63 64 |
# File 'lib/transit/package/post.rb', line 61 def return self.attributes['teaser'] unless self.attributes['teaser'].to_s.blank? .to_s end |
#timestamp ⇒ Object
Returns a timestamp formatted to a normal “post date”
51 52 53 54 |
# File 'lib/transit/package/post.rb', line 51 def return "" if self.post_date.nil? self.post_date.to_time.midnight.strftime("%B %d, %Y") end |