Class: WhatsonPost
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- WhatsonPost
- Defined in:
- app/models/whatson_post.rb
Defined Under Namespace
Modules: ShareThis
Class Method Summary collapse
- .comments_allowed? ⇒ Boolean
- .next(current_record) ⇒ Object
- .teaser_enabled_toggle! ⇒ Object
- .teasers_enabled? ⇒ Boolean
- .uncategorized ⇒ Object
Instance Method Summary collapse
- #category_ids=(ids) ⇒ Object
- #friendly_id_source ⇒ Object
- #live? ⇒ Boolean
-
#next ⇒ Object
next is now in << self.
- #prev ⇒ Object
Class Method Details
.comments_allowed? ⇒ Boolean
73 74 75 76 77 |
# File 'app/models/whatson_post.rb', line 73 def comments_allowed? RefinerySetting.find_or_set(:comments_allowed, true, { :scoping => 'whatson' }) end |
.next(current_record) ⇒ Object
67 68 69 70 71 |
# File 'app/models/whatson_post.rb', line 67 def next current_record self.send(:with_exclusive_scope) do where(["published_at > ? and draft = ?", current_record.published_at, false]).order("published_at ASC") end end |
.teaser_enabled_toggle! ⇒ Object
85 86 87 88 89 90 |
# File 'app/models/whatson_post.rb', line 85 def currently = RefinerySetting.find_or_set(:teasers_enabled, true, { :scoping => 'whatson' }) RefinerySetting.set(:teasers_enabled, {:value => !currently, :scoping => 'whatson'}) end |
.teasers_enabled? ⇒ Boolean
79 80 81 82 83 |
# File 'app/models/whatson_post.rb', line 79 def RefinerySetting.find_or_set(:teasers_enabled, true, { :scoping => 'whatson' }) end |
.uncategorized ⇒ Object
92 93 94 |
# File 'app/models/whatson_post.rb', line 92 def uncategorized WhatsonPost.live.reject { |p| p.categories.any? } end |
Instance Method Details
#category_ids=(ids) ⇒ Object
56 57 58 59 60 |
# File 'app/models/whatson_post.rb', line 56 def category_ids=(ids) self.categories = ids.reject{|id| id.blank?}.collect {|c_id| WhatsonCategory.find(c_id.to_i) rescue nil }.compact end |
#friendly_id_source ⇒ Object
62 63 64 |
# File 'app/models/whatson_post.rb', line 62 def friendly_id_source custom_url.present? ? custom_url : title end |
#live? ⇒ Boolean
52 53 54 |
# File 'app/models/whatson_post.rb', line 52 def live? !draft and published_at <= Time.now end |
#next ⇒ Object
next is now in << self
44 45 46 |
# File 'app/models/whatson_post.rb', line 44 def next WhatsonPost.next(self).first end |
#prev ⇒ Object
48 49 50 |
# File 'app/models/whatson_post.rb', line 48 def prev WhatsonPost.previous(self).first end |