Module: MongoidOccurrenceViews::Event::ClassMethods

Defined in:
lib/mongoid_occurrence_views/event.rb

Instance Method Summary collapse

Instance Method Details

#embeds_many_occurrences(options = {}) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/mongoid_occurrence_views/event.rb', line 12

def embeds_many_occurrences(options = {})
  embeds_many :occurrences, class_name: options.fetch(:class_name)
  accepts_nested_attributes_for :occurrences, allow_destroy: true, reject_if: :all_blank

  CreateExpandedOccurrencesView.call(self) unless embedded?
  CreateOccurrencesOrderingView.call(self) unless embedded?
end