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
-
#next_sibling_by_date ⇒ Object
Finds the page’s next sibling by date.
-
#previous_sibling_by_date ⇒ Object
Finds the page’s previous sibling by date.
- #upcoming? ⇒ Boolean
Instance Method Details
#next_sibling_by_date ⇒ Object
Finds the page’s next sibling by date. Returns nil if there isn’t one.
21 22 23 |
# File 'app/models/concerns/pages_core/page_model/dated_page.rb', line 21 def next_sibling_by_date siblings_by_date.where("starts_at >= ?", starts_at)&.first end |
#previous_sibling_by_date ⇒ Object
Finds the page’s previous sibling by date. Returns nil if there isn’t one.
27 28 29 |
# File 'app/models/concerns/pages_core/page_model/dated_page.rb', line 27 def previous_sibling_by_date siblings_by_date.where("starts_at < ?", starts_at)&.last end |
#upcoming? ⇒ Boolean
31 32 33 34 35 |
# File 'app/models/concerns/pages_core/page_model/dated_page.rb', line 31 def upcoming? return false unless ends_at? ends_at > Time.zone.now end |