Class: ActivePress::Post
- Defined in:
- lib/active_press/models/post.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.by_day(d) ⇒ Object
28 29 30 |
# File 'lib/active_press/models/post.rb', line 28 def self.by_day(d) where(:post_date_gmt => (d.beginning_of_day..d.end_of_day)) end |
.by_month(d) ⇒ Object
24 25 26 |
# File 'lib/active_press/models/post.rb', line 24 def self.by_month(d) where(:post_date_gmt => (d.beginning_of_month..d.end_of_month)) end |
.by_year(d) ⇒ Object
20 21 22 |
# File 'lib/active_press/models/post.rb', line 20 def self.by_year(d) where(:post_date_gmt => (d.beginning_of_year..d.end_of_year)) end |
Instance Method Details
#meta ⇒ Object
50 51 52 53 54 55 |
# File 'lib/active_press/models/post.rb', line 50 def .inject({}) do |hash, | hash[..to_sym] = . hash end end |
#next_post ⇒ Object
32 33 34 35 36 37 |
# File 'lib/active_press/models/post.rb', line 32 def next_post self.class.published.where(['id != ?', self.id])\ .where(:post_type => self.post_type)\ .where(['post_date_gmt >= ?', self.post_date_gmt])\ .order('post_date_gmt ASC').limit(1) end |
#previous_post ⇒ Object
39 40 41 42 43 44 |
# File 'lib/active_press/models/post.rb', line 39 def previous_post self.class.published.where(['id != ?', self.id])\ .where(:post_type => self.post_type)\ .where(['post_date_gmt <= ?', self.post_date_gmt])\ .order('post_date_gmt DESC').limit(1) end |
#to_param ⇒ Object
46 47 48 |
# File 'lib/active_press/models/post.rb', line 46 def to_param post_name end |