Module: PagesCore::PageModel::DatedPage

Extended by:
ActiveSupport::Concern
Included in:
Page
Defined in:
app/models/concerns/pages_core/page_model/dated_page.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#next_sibling_by_dateObject

Finds the page’s next sibling by date. Returns nil if there isn’t one.



59
60
61
# File 'app/models/concerns/pages_core/page_model/dated_page.rb', line 59

def next_sibling_by_date
  siblings_by_date.where(starts_at: starts_at..)&.first
end

#previous_sibling_by_dateObject

Finds the page’s previous sibling by date. Returns nil if there isn’t one.



65
66
67
# File 'app/models/concerns/pages_core/page_model/dated_page.rb', line 65

def previous_sibling_by_date
  siblings_by_date.where(starts_at: ...starts_at)&.last
end

#upcoming?Boolean

Returns:

  • (Boolean)


69
70
71
72
73
# File 'app/models/concerns/pages_core/page_model/dated_page.rb', line 69

def upcoming?
  return false unless ends_at?

  ends_at > Time.zone.now
end