Class: Pluto::Models::Feed
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Pluto::Models::Feed
- Defined in:
- lib/pluto/models.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.latest ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/pluto/models.rb', line 12 def self.latest # note: order by first non-null datetime field # coalesce - supported by sqlite (yes), postgres (yes) # note: if not published_at,touched_at or built_at use hardcoded 1999-01-01 for now order( "coalesce(published_at,touched_at,built_at,'1999-01-01') desc" ) end |
Instance Method Details
#published_at ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/pluto/models.rb', line 25 def published_at ## todo/fix: use a new name - do NOT squeeze convenience lookup into existing # db backed attribute if read_attribute(:published_at).present? read_attribute(:published_at) elsif read_attribute(:touched_at).present? ## try touched_at (aka updated (ATOM)) read_attribute(:touched_at) else ## try build_at (aka lastBuildDate (RSS)) read_attribute(:built_at) end end |
#published_at? ⇒ Boolean
21 22 23 |
# File 'lib/pluto/models.rb', line 21 def published_at? read_attribute(:published_at).present? end |