item_models 0.0.9 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9992d5a29e713769f3afca0e2715094e57eb6f15b97aeb1864e3e70b3d9185b9
4
- data.tar.gz: c05a9d94ce8ff1eef97645c9c262fc4c9a6b5fb72ed11f644aa7260e7474efeb
3
+ metadata.gz: 9347bfc3533841aa69d769771e76642b479c1d2785be5b0a2d3564ac201414fa
4
+ data.tar.gz: c22651d01977adf376a01549ad6428a2e434615ea96882305ddad18559c63852
5
5
  SHA512:
6
- metadata.gz: f13c5f6079c665c16368a497bd63114bac36f79c7571fdc840469130b00556de259901598a91cf697b185798e53760448ba3630b27971d67cce9b2761cfe39f7
7
- data.tar.gz: 1ea2479ce2640bb366d3db5b5ae0b6a71f7edf3b008128f11a7f8dc7a7b503fb71771e371d50555edbd8e95875563c44a7c857765448a34dea41d86b8eb0e378
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.9'
4
+ VERSION = '0.0.14'
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Activity < ItemAplicationRecord
3
+ class Activity < ItemApplicationRecord
4
4
  self.table_name = 'item_activities'
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class AvailabilityOption < ItemAplicationRecord
3
+ class AvailabilityOption < ItemApplicationRecord
4
4
  self.table_name = 'item_availability_options'
5
5
  end
data/lib/models/bundle.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Bundle < ItemAplicationRecord
3
+ require 'concerns/restorable'
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,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class ItemAplicationRecord < ActiveRecord::Base
3
+ class ItemApplicationRecord < ActiveRecord::Base
4
4
  self.abstract_class = true
5
5
  connects_to database: { writing: :item_model, reading: :item_model }
6
6
  end
@@ -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
@@ -10,4 +13,7 @@ class ItemListing < ItemApplicationRecord
10
13
  has_many :item_listing_variant_custom_fields, foreign_key: :channel_association_id
11
14
  has_many :item_listing_custom_fields, foreign_key: :channel_association_id
12
15
  has_many :item_listing_variant_images, foreign_key: :channel_association_id
16
+ has_one :category,
17
+ dependent: :destroy,
18
+ autosave: true
13
19
  end
@@ -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,10 +1,14 @@
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
- belongs_to :item_listing
8
- has_one :variant_listing_stock_allocation, foreign_key: :variant_association_id
9
+ belongs_to :item_listing, foreign_key: :channel_association_id
10
+ has_one :variant_listing_stock_allocation,
11
+ class_name: 'VariantListingStockAllocation',
12
+ foreign_key: :variant_association_id
9
13
  has_many :variant_listing_price_histories, foreign_key: :variant_association_id
10
14
  end
@@ -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,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: item_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - alexander
8
- - kevin
9
- autorequire:
8
+ autorequire:
10
9
  bindir: exe
11
10
  cert_chain: []
12
- date: 2020-06-25 00:00:00.000000000 Z
11
+ date: 2021-02-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
@@ -53,10 +52,9 @@ dependencies:
53
52
  - - "~>"
54
53
  - !ruby/object:Gem::Version
55
54
  version: '3.0'
56
- description:
55
+ description:
57
56
  email:
58
57
  - alxibra@gmail.com
59
- - ivanderkevin1@gmail.com
60
58
  executables: []
61
59
  extensions: []
62
60
  extra_rdoc_files: []
@@ -67,6 +65,7 @@ files:
67
65
  - lib/models/availability_option.rb
68
66
  - lib/models/bundle.rb
69
67
  - lib/models/bundle_variant.rb
68
+ - lib/models/concerns/restorable.rb
70
69
  - lib/models/image.rb
71
70
  - lib/models/item.rb
72
71
  - lib/models/item_application_record.rb
@@ -86,11 +85,11 @@ files:
86
85
  - lib/models/variant_listing_stock_allocation.rb
87
86
  - lib/models/variant_option.rb
88
87
  - lib/models/variant_option_association.rb
89
- homepage:
88
+ homepage:
90
89
  licenses:
91
90
  - MIT
92
91
  metadata: {}
93
- post_install_message:
92
+ post_install_message:
94
93
  rdoc_options: []
95
94
  require_paths:
96
95
  - lib
@@ -106,8 +105,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
105
  - !ruby/object:Gem::Version
107
106
  version: '0'
108
107
  requirements: []
109
- rubygems_version: 3.0.3
110
- signing_key:
108
+ rubygems_version: 3.0.6
109
+ signing_key:
111
110
  specification_version: 4
112
111
  summary: gem for active record item models
113
112
  test_files: []