Module: SubjModels::OrderItemModule

Includes:
TypesSupport::ItemTypes, ValuesChecker
Defined in:
lib/subj_models/order_item.rb

Constant Summary

Constants included from TypesSupport::ItemTypes

TypesSupport::ItemTypes::EVENT, TypesSupport::ItemTypes::ITEM_TYPES, TypesSupport::ItemTypes::PRODUCT

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ValuesChecker

#check_string_for_int

Class Method Details

.included(including_class) ⇒ Object



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
# File 'lib/subj_models/order_item.rb', line 11

def self.included(including_class)

  including_class.class_eval do

    include SubjModels::ComprisingExternalId

    # before_destroy :decrease_nomenclature_popularity
    # after_create :increase_nomenclature_popularity

    enum item_type: ITEM_TYPES

    belongs_to :order
    belongs_to :event
    belongs_to :nomenclature_variety
    belongs_to :nomenclature
    belongs_to :quality

    validates :item_type, presence: true, inclusion: { in: item_types.keys }
    validates :item_price, :item_count, presence: true

    scope :order_id, -> (order_id) { parent_id_scope("order", order_id) }
    scope :without_autoadded, -> { where(autoaddedposition: [nil, false]) }

  end

end

Instance Method Details

#to_sObject



38
39
40
# File 'lib/subj_models/order_item.rb', line 38

def to_s
  id.to_s # TODO
end