subj_models 0.1.04 → 0.1.05

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6765247548ac23e7be393451439a03b56a857825
4
- data.tar.gz: bddc812ec6f1b1811c367a535f87cf38256dd36d
3
+ metadata.gz: 82d89cdbd2b65439c84b982cb18691fbce5695c5
4
+ data.tar.gz: c472c01f696b0ca810e2a050bb98dfd17337a510
5
5
  SHA512:
6
- metadata.gz: ad866aa40debc766de5c9b025af568c25c98d07f23c62d17e630eb576e0562c8ce00c323a5f46d53560ef6aca3f97b644888f87abf5c00d52fef57584b90f941
7
- data.tar.gz: d598b3ac3496b583a221c6412f8bce5fa5b2c03a43491e3d1ad60fddeda4eb2fa9c7301d511df5f6c7afb628c5c2ec8f0a44f64ccd01f832cf4f3cd6fc190a0c
6
+ metadata.gz: f07d137c04074a9eea278c5c204f4833f66e53fc2f490de16c47d96199affa66faaf02f6afdf53ac65f9caf7edaf49b5ed75bb3b26c500b4da176dbf03a19a19
7
+ data.tar.gz: f2edcda45a78ba37c40fd6b94265086c1af2ca0fd60352571ffb78b37927453aa298dfd06fabadf307b9ed82055c56a2863082c5795519b4c6ce52f4f0957baa
@@ -2,47 +2,54 @@ module SubjModels
2
2
 
3
3
  module User
4
4
 
5
- include ComprisingExternalId
6
- include TypesSupport::UserTypes
7
- include TypesSupport::CardReceiveTypes
8
- include RademadeAdmin::UserModule
9
- include SharedScopes
10
- include ValuesChecker
11
-
12
- enum user_type: USER_TYPES
13
- enum card_receive_type: CARD_RECEIVE_TYPES
14
-
15
- has_many :orders
16
- has_many :user_specialization_approvals, dependent: :destroy
17
- has_many :user_cards, dependent: :destroy
18
- has_one :user_work_place, dependent: :destroy
19
- has_many :user_delivery_addresses, dependent: :destroy
20
-
21
- has_and_belongs_to_many :user_specializations
22
-
23
- belongs_to :document_file
24
- belongs_to :city
25
- belongs_to :avatar, class_name: "DocumentFile"
26
-
27
- validates :first_name, :last_name, presence: true,
28
- on: :update,
29
- unless: lambda { |user| user.legal_person? || user.skip_validations }
30
- validates :email, uniqueness: { case_sensitive: false }, presence: true,
31
- on: :update,
32
- unless: :skip_validations
33
- validates :phone, uniqueness: { case_sensitive: false }, presence: true,
34
- on: :update,
35
- unless: :skip_validations
36
- validates :user_type, inclusion: { in: user_types.keys },
37
- on: :update,
38
- unless: :skip_validations
39
-
40
-
41
- attr_accessor :skip_validations
42
-
43
- scope :external_id, -> external_id do
44
- external_id ? where(external_id: external_id) : User.none
45
- end
5
+ def self.included(including_class)
6
+
7
+ including_class.class_eval do
8
+
9
+ include ComprisingExternalId
10
+ include TypesSupport::UserTypes
11
+ include TypesSupport::CardReceiveTypes
12
+ include RademadeAdmin::UserModule
13
+ include SharedScopes
14
+ include ValuesChecker
15
+
16
+ enum user_type: USER_TYPES
17
+ enum card_receive_type: CARD_RECEIVE_TYPES
18
+
19
+ has_many :orders
20
+ has_many :user_specialization_approvals, dependent: :destroy
21
+ has_many :user_cards, dependent: :destroy
22
+ has_one :user_work_place, dependent: :destroy
23
+ has_many :user_delivery_addresses, dependent: :destroy
24
+
25
+ has_and_belongs_to_many :user_specializations
26
+
27
+ belongs_to :document_file
28
+ belongs_to :city
29
+ belongs_to :avatar, class_name: "DocumentFile"
30
+
31
+ validates :first_name, :last_name, presence: true,
32
+ on: :update,
33
+ unless: lambda { |user| user.legal_person? || user.skip_validations }
34
+ validates :email, uniqueness: { case_sensitive: false }, presence: true,
35
+ on: :update,
36
+ unless: :skip_validations
37
+ validates :phone, uniqueness: { case_sensitive: false }, presence: true,
38
+ on: :update,
39
+ unless: :skip_validations
40
+ validates :user_type, inclusion: { in: user_types.keys },
41
+ on: :update,
42
+ unless: :skip_validations
43
+
44
+ attr_accessor :skip_validations
45
+
46
+ scope :external_id, -> external_id do
47
+ external_id ? where(external_id: external_id) : User.none
48
+ end
49
+
50
+ end
51
+
52
+ end
46
53
 
47
54
  def natural_person?
48
55
  user_type == USER_TYPES.key(NATURAL_PERSON)
@@ -1,3 +1,3 @@
1
1
  module SubjModels
2
- VERSION = "0.1.04"
2
+ VERSION = "0.1.05"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subj_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.04
4
+ version: 0.1.05
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denys Dvoriashyn