module DateBook::ActsAsEvent
Mixin to allow acts_as_event
behavior in Event
model
Public Instance Methods
acts_as_event(_options = {})
click to toggle source
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
# File lib/date_book/concerns/acts_as_event.rb, line 8 def acts_as_event(_options = {}) acts_as_ownable delegate :all_day, :duration, to: :schedule validates_presence_of :name, :slug, :calendar # FriendlyId Gem extend FriendlyId friendly_id :name, use: :slugged # Schedulable Gem acts_as_schedulable :schedule, occurrences: :event_occurrences # Relationships belongs_to :calendar # Nested Forms gem accepts_nested_attributes_for :schedule # Scopes scope :ending_after, (lambda do |start_date| where id: ::EventOccurrence.ending_after(start_date).event_ids end) scope :starting_before, (lambda do |end_date| where id: ::EventOccurrence.starting_before(end_date).event_ids end) include InstanceMethods extend ClassMethods end