Sha256: 2c4d9c392e71b023abb743bcd1465a273ce8d187d95a22ebdde6e4972fc53cbe

Contents?: true

Size: 732 Bytes

Versions: 5

Compression:

Stored size: 732 Bytes

Contents

require 'subj_models/concerns/comprising_external_id'

module SubjModels

  module Event

    def self.included(including_class)

      including_class.class_eval do

        include SubjModels::ComprisingExternalId

        belongs_to :manager
        belongs_to :event_type
        belongs_to :nomenclature
        belongs_to :document_file

        has_one :event_schedule

        validates :document_file, presence: true

        scope :today_events, -> {
          includes(:event_schedule).where(event_schedule: { event_date: DateTime.now.beginning_of_day..DateTime.now.end_of_day } )
        }
        scope :is_public, -> { where(is_public: true) }

      end

    end

    def to_s
      id.to_s # TODO
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
subj_models-0.4.1 lib/subj_models/event.rb
subj_models-0.4 lib/subj_models/event.rb
subj_models-0.3.8 lib/subj_models/event.rb
subj_models-0.3.7 lib/subj_models/event.rb
subj_models-0.3.6 lib/subj_models/event.rb