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.
18 19 20 21 22 23 24 |
# File 'app/models/concerns/pages_core/page_model/dated_page.rb', line 18 def next_sibling_by_date siblings = siblings_by_date return unless siblings.any? siblings[(siblings.to_a.index(self) + 1)...siblings.length] .try(&: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 30 31 32 |
# File 'app/models/concerns/pages_core/page_model/dated_page.rb', line 27 def previous_sibling_by_date siblings = siblings_by_date return unless siblings.any? siblings[0...siblings.to_a.index(self)].try(&:last) end |
#upcoming? ⇒ Boolean
34 35 36 37 |
# File 'app/models/concerns/pages_core/page_model/dated_page.rb', line 34 def upcoming? return false unless ends_at? ends_at > Time.zone.now end |