Module: DateBook::ActsAsEvent
- Defined in:
- lib/date_book/concerns/acts_as_event.rb
Overview
Mixin to allow acts_as_event behavior in Event model
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Instance Method Summary collapse
-
#acts_as_event(_options = {}) ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength.
Instance Method Details
#acts_as_event(_options = {}) ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/date_book/concerns/acts_as_event.rb', line 8 def acts_as_event( = {}) 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 |