blob: 94a22e364524e5f0861b5ca17e34b09ec4788c80 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
class Event < ApplicationRecord
# Associations
has_many :occurrences
belongs_to :node
# Callbacks
after_save :generate_occurences
# Instance Methods
def occurrences_in_range start_time, end_time
self.occurrences.where(
"start_time > ? AND end_time < ?",
start_time, end_time
)
end
private
def generate_occurences
Occurrence.generate self
end
end
|