Sha256: 35fd07eeaf99493790bccb6eca6ffc74e3ba1d1b5886df7a52486597ac14f05d

Contents?: true

Size: 722 Bytes

Versions: 49

Compression:

Stored size: 722 Bytes

Contents

require 'subj_models/concerns/comprising_external_id'

module SubjModels

  module EventBookingModule

    def self.included(including_class)

      including_class.class_eval do

        include SubjModels::ComprisingExternalId

        belongs_to :order
        belongs_to :user
        belongs_to :event

        validates :user, uniqueness: { scope: :event }

        scope :user_id , -> (user_id) {where(user_id: user_id)}
        scope :event_id , -> (event_id) {where(event_id: event_id)}
        scope :only_new, -> (condition) do
          if condition
            where(external_id: nil)
          else
            all
          end
        end

      end

    end

    def to_s
      id.to_s
    end

  end

end

Version data entries

49 entries across 49 versions & 2 rubygems

Version Path
subj_sub_models-0.0.3.9 lib/subj_models/event_booking.rb
subj_sub_models-0.0.3.8 lib/subj_models/event_booking.rb
subj_sub_models-0.0.3.7 lib/subj_models/event_booking.rb
subj_sub_models-0.0.3.6 lib/subj_models/event_booking.rb
subj_sub_models-0.0.3.5 lib/subj_models/event_booking.rb
subj_sub_models-0.0.3.4 lib/subj_models/event_booking.rb
subj_sub_models-0.0.3.3 lib/subj_models/event_booking.rb
subj_sub_models-0.0.3.1 lib/subj_models/event_booking.rb
subj_sub_models-0.0.3 lib/subj_models/event_booking.rb
subj_sub_models-0.0.2 lib/subj_models/event_booking.rb
subj_sub_models-0.0.1 lib/subj_models/event_booking.rb
subj_models-0.6.9 lib/subj_models/event_booking.rb
subj_models-0.6.8 lib/subj_models/event_booking.rb
subj_models-0.6.7 lib/subj_models/event_booking.rb
subj_models-0.6.5 lib/subj_models/event_booking.rb
subj_models-0.6.4 lib/subj_models/event_booking.rb
subj_models-0.6.3 lib/subj_models/event_booking.rb
subj_models-0.6.2 lib/subj_models/event_booking.rb
subj_models-0.6.1 lib/subj_models/event_booking.rb
subj_models-0.6.0 lib/subj_models/event_booking.rb