item_models 0.0.13 → 0.0.14

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
  SHA256:
3
- metadata.gz: fa90ceaa3413fb8f1eff246593217cb54a380e8e6fb5b06ee31b1bdd2cf07ac1
4
- data.tar.gz: f5e889db45c50e4a2a640f23998d12b615e31f1619bec7618ff92ff002fea366
3
+ metadata.gz: 9347bfc3533841aa69d769771e76642b479c1d2785be5b0a2d3564ac201414fa
4
+ data.tar.gz: c22651d01977adf376a01549ad6428a2e434615ea96882305ddad18559c63852
5
5
  SHA512:
6
- metadata.gz: f0446a42158a50ae996d0b3d9a551c711c320e485a43e3696ee5ba442b9d8aba8108e6917086707c0bd699b0f6b088f29d9e3e9795af510102a6b89d7acc1273
7
- data.tar.gz: 0f83a1f14e3083d918a062fcb8220161815e7e1a6dd2de336f7fc5e47f71a8ecae1c1e5c8860aadb398641f735c4e03211ea1d11d7bc4ae055e1f9c7f17c68f7
6
+ metadata.gz: cdc53974c85bbe6171284fdb47cf7700bb959386d10dd1485722566e40fa6b5c189f861f2e04b900ac23e3a44763ab456a1d979de81a331d3c57707627e7071c
7
+ data.tar.gz: 6bd7b129a0507bbcee1dab62f6a5a74895042b4800d366c1232d013521165972009889dce1b2a1895d7f89457f6adbf248105ca8abda6fad1fdf5c4f9e7f23bc
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ItemModels
4
- VERSION = '0.0.13'
4
+ VERSION = '0.0.14'
5
5
  end
data/lib/models/bundle.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concerns/restorable'
3
4
  class Bundle < ItemApplicationRecord
4
5
  self.table_name = 'item_bundles'
6
+ include ::Restorable
5
7
 
6
8
  belongs_to :variant
7
9
  belongs_to :item
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concerns/restorable'
3
4
  class BundleVariant < ItemApplicationRecord
4
5
  self.table_name = 'item_bundle_variants'
6
+ include ::Restorable
5
7
 
6
8
  belongs_to :bundle
7
9
  belongs_to :variant
@@ -0,0 +1,28 @@
1
+ module Restorable
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ acts_as_paranoid column: :removed, sentinel_value: false
6
+ acts_as_paranoid column: :removed_at, sentinel_value: false
7
+
8
+ # It seems paranoia bug: method_missing `deleted_at`
9
+ # when restore with `recovery_window`
10
+ alias_attribute :deleted_at, :removed_at
11
+
12
+ private
13
+
14
+ def paranoia_restore_attributes
15
+ {
16
+ removed_at: nil,
17
+ removed: false
18
+ }
19
+ end
20
+
21
+ def paranoia_destroy_attributes
22
+ {
23
+ removed_at: current_time_from_proper_timezone,
24
+ removed: nil
25
+ }
26
+ end
27
+ end
28
+ end
data/lib/models/image.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concerns/restorable'
3
4
  class Image < ItemApplicationRecord
4
5
  self.table_name = 'item_images'
6
+ include ::Restorable
5
7
 
6
8
  belongs_to :item
7
9
  has_many :item_listing_images
data/lib/models/item.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concerns/restorable'
3
4
  class Item < ItemApplicationRecord
5
+ include ::Restorable
6
+
4
7
  has_many :variants
5
8
  has_many :item_listings
6
9
  has_many :bundles
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concerns/restorable'
3
4
  class ItemListing < ItemApplicationRecord
4
5
  self.table_name = 'item_channel_associations'
6
+ include ::Restorable
7
+
5
8
  belongs_to :item
6
9
  has_many :variant_listings, foreign_key: :channel_association_id
7
10
  has_many :item_listing_images, foreign_key: :channel_association_id
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concerns/restorable'
3
4
  class ItemListingBrand < ItemApplicationRecord
4
5
  self.table_name = 'item_channel_association_brands'
6
+ include ::Restorable
5
7
 
6
8
  belongs_to :item_listing, foreign_key: :channel_association_id
7
9
  end
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concerns/restorable'
3
4
  class ItemListingCategory < ItemApplicationRecord
4
5
  self.table_name = 'item_channel_association_categories'
6
+ include ::Restorable
5
7
 
6
8
  belongs_to :item_listing, foreign_key: :channel_association_id
7
9
  end
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concerns/restorable'
3
4
  class ItemListingCustomField < ItemApplicationRecord
4
5
  self.table_name = 'item_channel_association_custom_fields'
6
+ include ::Restorable
5
7
 
6
8
  belongs_to :item_listing, foreign_key: :channel_association_id
7
9
  belongs_to :variant
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concerns/restorable'
3
4
  class ItemListingImage < ItemApplicationRecord
4
5
  self.table_name = 'item_channel_association_images'
6
+ include ::Restorable
7
+
5
8
  belongs_to :image
6
9
  belongs_to :item_listing, foreign_key: :channel_association_id
7
10
  end
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concerns/restorable'
3
4
  class Variant < ItemApplicationRecord
4
5
  self.table_name = 'item_variants'
6
+ include ::Restorable
7
+
5
8
  belongs_to :item
6
9
  has_many :variant_images, foreign_key: :item_variant_id
7
10
  has_many :bundles
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concerns/restorable'
3
4
  class VariantImage < ItemApplicationRecord
4
5
  self.table_name = 'item_variant_images'
6
+ include ::Restorable
5
7
 
6
8
  belongs_to :image
7
9
  belongs_to :variant
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concerns/restorable'
3
4
  class VariantListing < ItemApplicationRecord
4
5
  self.table_name = 'item_channel_association_variant_associations'
6
+ include ::Restorable
5
7
 
6
8
  belongs_to :variant
7
9
  belongs_to :item_listing, foreign_key: :channel_association_id
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concerns/restorable'
3
4
  class VariantOption < ItemApplicationRecord
4
5
  self.table_name = 'item_variant_options'
6
+ include ::Restorable
5
7
 
6
8
  has_many :variant_option_associations, foreign_key: :option_id
7
9
  end
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concerns/restorable'
3
4
  class VariantOptionAssociation < ItemApplicationRecord
4
5
  self.table_name = 'item_variant_option_associations'
6
+ include ::Restorable
5
7
 
6
8
  belongs_to :variant_option, foreign_key: :option_id
7
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: item_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - alexander
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-13 00:00:00.000000000 Z
11
+ date: 2021-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- description:
55
+ description:
56
56
  email:
57
57
  - alxibra@gmail.com
58
58
  executables: []
@@ -65,6 +65,7 @@ files:
65
65
  - lib/models/availability_option.rb
66
66
  - lib/models/bundle.rb
67
67
  - lib/models/bundle_variant.rb
68
+ - lib/models/concerns/restorable.rb
68
69
  - lib/models/image.rb
69
70
  - lib/models/item.rb
70
71
  - lib/models/item_application_record.rb
@@ -84,11 +85,11 @@ files:
84
85
  - lib/models/variant_listing_stock_allocation.rb
85
86
  - lib/models/variant_option.rb
86
87
  - lib/models/variant_option_association.rb
87
- homepage:
88
+ homepage:
88
89
  licenses:
89
90
  - MIT
90
91
  metadata: {}
91
- post_install_message:
92
+ post_install_message:
92
93
  rdoc_options: []
93
94
  require_paths:
94
95
  - lib
@@ -104,8 +105,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  - !ruby/object:Gem::Version
105
106
  version: '0'
106
107
  requirements: []
107
- rubygems_version: 3.0.3
108
- signing_key:
108
+ rubygems_version: 3.0.6
109
+ signing_key:
109
110
  specification_version: 4
110
111
  summary: gem for active record item models
111
112
  test_files: []