Class: Pluto::Models::Item

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/pluto/models.rb

Overview

class Feed

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.latestObject



46
47
48
49
50
51
52
# File 'lib/pluto/models.rb', line 46

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,'1999-01-01') desc" )
end

Instance Method Details

#published_atObject



58
59
60
61
62
63
64
65
66
67
# File 'lib/pluto/models.rb', line 58

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)
  else  ## try touched_at (aka updated)
    read_attribute(:touched_at)
  end
end

#published_at?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/pluto/models.rb', line 54

def published_at?
  read_attribute(:published_at).present?
end