Module: DateBook::ActsAsEvent::InstanceMethods
- Defined in:
- lib/date_book/concerns/acts_as_event.rb
Overview
Instance Methods
Instance Method Summary collapse
- #next_occurrence(occurrence = nil) ⇒ Object
- #popover_url(occurrence = nil) ⇒ Object
- #previous_occurrence(occurrence = nil) ⇒ Object
- #schedule ⇒ Object
- #url(occurrence = nil) ⇒ Object
Instance Method Details
#next_occurrence(occurrence = nil) ⇒ Object
56 57 58 59 |
# File 'lib/date_book/concerns/acts_as_event.rb', line 56 def next_occurrence(occurrence = nil) after = occurrence.present? ? occurrence.end_date + 1.second : Time.now event_occurrences.ending_after(after).ascending.first end |
#popover_url(occurrence = nil) ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/date_book/concerns/acts_as_event.rb', line 68 def popover_url(occurrence = nil) DateBook::Engine .routes .url_helpers .popover_calendar_event_path( calendar, slug, occurrence_id: occurrence&.id ) end |
#previous_occurrence(occurrence = nil) ⇒ Object
51 52 53 54 |
# File 'lib/date_book/concerns/acts_as_event.rb', line 51 def previous_occurrence(occurrence = nil) before = occurrence.present? ? occurrence.start_date : Time.now event_occurrences.starting_before(before).descending.first end |
#schedule ⇒ Object
44 45 46 47 48 49 |
# File 'lib/date_book/concerns/acts_as_event.rb', line 44 def schedule super || build_schedule( date: Time.now.to_date, time: Time.now.to_s(:time) ) end |