Sha256: f917a6caae936a074b08f3918302f6846b4d46d57239ff927dc2dcdc5bd82798

Contents?: true

Size: 933 Bytes

Versions: 2

Compression:

Stored size: 933 Bytes

Contents

require 'subj_models/services/values_checker'
require 'subj_models/services/types_support'
require 'subj_models/concerns/comprising_external_id'

module SubjModels

  module EventSchedule

    include SubjModels::TypesSupport::EventTypes
    include SubjModels::ValuesChecker

    def self.included(including_class)

      including_class.class_eval do

        include SubjModels::ComprisingExternalId

        enum event_type: EVENT_TYPES

        belongs_to :event
        belongs_to :city
        belongs_to :office

        has_many :order_items

        validates :event_type, presence: true, inclusion: { in: event_types.keys }
        validates :event_date, :event_price, :title, presence: true

        scope :event_id, -> (event_id) { parent_id_scope("event", event_id) }

      end

    end

    def to_s
      id.to_s # TODO
    end

    def event_type=(value)
      super(check_string_for_int(value))
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
subj_models-0.4.1 lib/subj_models/event_schedule.rb
subj_models-0.4 lib/subj_models/event_schedule.rb