item_models 0.0.2 → 0.0.7

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: e27ba15bf99b747a66a76cfa35b29db612062a8c03b0377c526a4803cd6538ca
4
- data.tar.gz: f8f4fed63d7125e6a210cbde9c6c4df3e177c28a6fe0db1d77267399d9035d36
3
+ metadata.gz: f0214e0787fb28bfa06ffb646c088a0de1bb501576fab9edbda16cf07e1d2ea7
4
+ data.tar.gz: 49fb1f77bd36cbb18df9624f0f90a59fab4382acfc428b7be9c16fa0be8d1a1f
5
5
  SHA512:
6
- metadata.gz: d09fa132f45c9bb9ccc549236e7adb6a4bb93e33dc97e3ec57cf6df01722ba2f9618a644946b69613b720b5178b9a8e6df12e6216ad24bd4e87573985059207e
7
- data.tar.gz: 1b7999314b02af48bea7e0979ade2ea7b5068f2a3b93287d1d93b48953eafca71e2cf70334d088832ef060212780e5c1f5eddd4479f843e21755d47019e178b5
6
+ metadata.gz: 194e8ae07352faf9bbcdc008f096cad4dd6c0641946b86a41e97061dfc707b4ea483850c58ba744b6f508640429072d1447b8bc14b025351b44c2155660bbe21
7
+ data.tar.gz: ce5f99a81915dc797bb9dd63ebfe25e1200278d13b75b28099e612e2bd533f8b906cb5be9421daa6ccf83b355e08a69dded0c656944e032c71843140c2df0b11
@@ -6,6 +6,7 @@ module ItemModels
6
6
  class Error < StandardError; end
7
7
  # Your code goes here...
8
8
  def self.load
9
+ require directory + '/lib/models/item_application_record'
9
10
  files.each {|file| require file }
10
11
  end
11
12
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ItemModels
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.7'
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Activity < ApplicationRecord
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 < ApplicationRecord
3
+ class AvailabilityOption < ItemApplicationRecord
4
4
  self.table_name = 'item_availability_options'
5
5
  end
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Bundle < ApplicationRecord
3
+ class Bundle < ItemApplicationRecord
4
4
  self.table_name = 'item_bundles'
5
+
6
+ belongs_to :variant
7
+ belongs_to :item
8
+ has_many :bundle_variants
5
9
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class BundleVariant < ApplicationRecord
3
+ class BundleVariant < ItemApplicationRecord
4
4
  self.table_name = 'item_bundle_variants'
5
+
6
+ belongs_to :bundle
7
+ belongs_to :variant
5
8
  end
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Image < ApplicationRecord
3
+ class Image < ItemApplicationRecord
4
4
  self.table_name = 'item_images'
5
+
6
+ belongs_to :item
7
+ has_many :item_listing_images
8
+ has_many :variant_images, foreign_key: :item_image_id
9
+ has_many :master_catalog_images
10
+ has_many :item_listing_variant_custom_fields
5
11
  end
@@ -1,4 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Item < ApplicationRecord
3
+ class Item < ItemApplicationRecord
4
+ has_many :variants
5
+ has_many :item_listings
6
+ has_many :bundles
7
+ has_many :images
4
8
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ItemApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ connects_to database: { writing: :item_model, reading: :item_model }
6
+ end
@@ -1,5 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class ItemListing < ApplicationRecord
3
+ class ItemListing < ItemApplicationRecord
4
4
  self.table_name = 'item_channel_associations'
5
+ belongs_to :item
6
+ has_many :variant_listings, foreign_key: :channel_association_id
7
+ has_many :item_listing_images, foreign_key: :channel_association_id
8
+ has_many :item_listing_categories, foreign_key: :channel_association_id
9
+ has_many :item_listing_brands, foreign_key: :channel_association_id
10
+ has_many :item_listing_variant_custom_fields, foreign_key: :channel_association_id
11
+ has_many :item_listing_custom_fields, foreign_key: :channel_association_id
12
+ has_many :item_listing_variant_images, foreign_key: :channel_association_id
5
13
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class ItemListingBrand < ApplicationRecord
3
+ class ItemListingBrand < ItemApplicationRecord
4
4
  self.table_name = 'item_channel_association_brands'
5
+
6
+ belongs_to :item_listing, foreign_key: :channel_association_id
5
7
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class ItemListingCategory < ApplicationRecord
3
+ class ItemListingCategory < ItemApplicationRecord
4
4
  self.table_name = 'item_channel_association_categories'
5
+
6
+ belongs_to :item_listing, foreign_key: :channel_association_id
5
7
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class ItemListingCustomField < ApplicationRecord
3
+ class ItemListingCustomField < ItemApplicationRecord
4
4
  self.table_name = 'item_channel_association_custom_fields'
5
+
6
+ belongs_to :item_listing, foreign_key: :channel_association_id
7
+ belongs_to :variant
5
8
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class ItemListingImage < ApplicationRecord
3
+ class ItemListingImage < ItemApplicationRecord
4
4
  self.table_name = 'item_channel_association_images'
5
+ belongs_to :image
6
+ belongs_to :item_listing, foreign_key: :channel_association_id
5
7
  end
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class ItemListingVariantCustomField < ApplicationRecord
3
+ class ItemListingVariantCustomField < ItemApplicationRecord
4
4
  self.table_name = 'item_channel_association_variant_images'
5
+
6
+ belongs_to :item_listing, foreign_key: :channel_association_id
7
+ belongs_to :variant
8
+ belongs_to :image
5
9
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class ItemListingVariantImage < ApplicationRecord
3
+ class ItemListingVariantImage < ItemApplicationRecord
4
4
  self.table_name = 'item_channel_association_variant_images'
5
5
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class MasterCatalog < ApplicationRecord
3
+ class MasterCatalog < ItemApplicationRecord
4
4
  self.table_name = 'item_variant_master_assocs'
5
+
6
+ belongs_to :variant
7
+ has_many :master_catalog_images, foreign_key: :master_assoc_id
5
8
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class MasterCatalogImage < ApplicationRecord
3
+ class MasterCatalogImage < ItemApplicationRecord
4
4
  self.table_name = 'item_variant_master_image_assocs'
5
+
6
+ belongs_to :master_catalog, foreign_key: :master_assoc_id
7
+ belongs_to :image, foreign_key: :image_id
5
8
  end
@@ -1,5 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Variant < ApplicationRecord
3
+ class Variant < ItemApplicationRecord
4
4
  self.table_name = 'item_variants'
5
+ belongs_to :item
6
+ has_many :variant_images, foreign_key: :item_variant_id
7
+ has_many :bundles
8
+ has_many :variant_listings, foreign_key: :variant_id
9
+ has_many :item_listing_variant_images, foreign_key: :variant_id
10
+ has_many :item_listing_variant_custom_field, foreign_key: :variant_id
11
+ has_many :item_listing_custom_field, foreign_key: :variant_id
12
+ has_one :master_catalog, foreign_key: :variant_id
5
13
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class VariantImage < ApplicationRecord
3
+ class VariantImage < ItemApplicationRecord
4
4
  self.table_name = 'item_variant_images'
5
+
6
+ belongs_to :image
7
+ belongs_to :variant
5
8
  end
@@ -1,5 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class VariantListing < ApplicationRecord
3
+ class VariantListing < ItemApplicationRecord
4
4
  self.table_name = 'item_channel_association_variant_associations'
5
+
6
+ belongs_to :variant
7
+ belongs_to :item_listing
8
+ has_many :variant_listing_stock_allocations, foreign_key: :variant_association_id
9
+ has_many :variant_listing_price_histories, foreign_key: :variant_association_id
5
10
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class VariantListingPriceHistory < ApplicationRecord
3
+ class VariantListingPriceHistory < ItemApplicationRecord
4
4
  self.table_name = 'item_channel_association_variant_association_stock_allocations'
5
+
6
+ belongs_to :variant_listing, foreign_key: :variant_association_id
5
7
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class VariantListingStockAllocation < ApplicationRecord
3
+ class VariantListingStockAllocation < ItemApplicationRecord
4
4
  self.table_name = 'item_channel_association_variant_association_stock_allocations'
5
+
6
+ belongs_to :variant_listing, foreign_key: :variant_association_id
5
7
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class VariantOption < ApplicationRecord
3
+ class VariantOption < ItemApplicationRecord
4
4
  self.table_name = 'item_variant_options'
5
+
6
+ has_many :variant_option_associations, foreign_key: :option_id
5
7
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class VariantOptionAssociation < ApplicationRecord
3
+ class VariantOptionAssociation < ItemApplicationRecord
4
4
  self.table_name = 'item_variant_option_associations'
5
+
6
+ belongs_to :variant_option, foreign_key: :option_id
5
7
  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.2
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - alexander
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-29 00:00:00.000000000 Z
11
+ date: 2020-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,6 +67,7 @@ files:
67
67
  - lib/models/bundle_variant.rb
68
68
  - lib/models/image.rb
69
69
  - lib/models/item.rb
70
+ - lib/models/item_application_record.rb
70
71
  - lib/models/item_listing.rb
71
72
  - lib/models/item_listing_brand.rb
72
73
  - lib/models/item_listing_category.rb