item_models 0.0.1 → 0.0.6

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: 314088a7af4e6bd0c431eba03e472e7d07396e3469411bc66b13ed8fdcca1d1b
4
- data.tar.gz: c76223de463bc63858eacbb680a66c3df393625f6970dc1432cdc5c885725313
3
+ metadata.gz: 820422d0524d4604444fa41f0e4dc598e5cfb75dcbccdfced3febc051c9b1efa
4
+ data.tar.gz: 9579065ab3a09ed3f38023c8db64722a9b35362ba579aa60ea1006c74cf3737a
5
5
  SHA512:
6
- metadata.gz: dce1a3fa5b1fcead3696d2e6a69d2f572b6f8f922d708e9ad442424b71acd7189de1a539ff4f7f66f9c084f82e4b34c2b88b3d7e2d1ad37a26283550af788b75
7
- data.tar.gz: 60f5eb9acbb9496e15e43b773d1589c4387f7b713d846152db9702af2e9173392663a255d6fc71ce4cdfce96434e98b9a26c47bf547c53282a77d9319e84cbee
6
+ metadata.gz: 7f09629748137014df85d12ceb6ed1c8711bcf47b1f0eff02faebcdc9f7473eac7c3ea17903bd4713f019140ad76e7dba7c991531f6113f1ffcf9ade634ea959
7
+ data.tar.gz: 484b8b70b5300129be91b0b57c8540c5b97ae81fa44394c1563f708c710b451ac5d36453c70e5fc67a9c098e58a8605be73156a1ed06381fa6d85bac45bda249
@@ -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.1'
4
+ VERSION = '0.0.6'
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class AvailabilityOption < ApplicationRecord
3
+ class Activity < ItemAplicationRecord
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 < ItemAplicationRecord
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 < ItemAplicationRecord
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 ItemAplicationRecord < 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.1
4
+ version: 0.0.6
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