12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/mongoid_occurrence_views/event/occurrence.rb', line 12
def embedded_in_event(options = {})
field :dtstart, type: DateTime
field :dtend, type: DateTime
field :all_day, type: Boolean
field :schedule, type: MongoidIceCubeExtension::Schedule
field :schedule_dtend, type: Time
embedded_in :event, class_name: options.fetch(:class_name, nil)
embeds_many :daily_occurrences, class_name: 'MongoidOccurrenceViews::Event::Occurrence::DailyOccurrence', order: :dtstart.asc
validates_presence_of :dtstart
validates_presence_of :dtend
before_validation :nil_schedule, unless: :recurring?
after_validation :adjust_dates_for_all_day, if: :changed?
after_validation :assign_daily_occurrences, if: :changed?
end
|