Class: TbCommerce::ProductSku
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- TbCommerce::ProductSku
- Defined in:
- app/models/tb_commerce/product_sku.rb
Class Method Summary collapse
-
.with_option_ids(option_ids_list) ⇒ Object
Return SKU records that support the provided list of option IDs.
Instance Method Summary collapse
- #description ⇒ Object
-
#has_options?(option_ids_list) ⇒ Boolean
Return true if the current record supports the supplied list of option IDs.
- #price ⇒ Object
Class Method Details
.with_option_ids(option_ids_list) ⇒ Object
Return SKU records that support the provided list of option IDs
-
option_ids_list: Array of integer values corresponding to TbCommcerce::Option
29 30 31 32 33 |
# File 'app/models/tb_commerce/product_sku.rb', line 29 def self.with_option_ids(option_ids_list) return includes(:options).to_a.select do |sku| sku.(option_ids_list) end end |
Instance Method Details
#description ⇒ Object
17 18 19 |
# File 'app/models/tb_commerce/product_sku.rb', line 17 def description return product.title end |
#has_options?(option_ids_list) ⇒ Boolean
Return true if the current record supports the supplied list of option IDs
-
option_ids_list: Array of integer values corresponding to TbCommcerce::Option
39 40 41 42 43 44 45 46 |
# File 'app/models/tb_commerce/product_sku.rb', line 39 def (option_ids_list) option_ids_list.each do |option_id| if !self.option_ids.include?(option_id) return false end end return true end |
#price ⇒ Object
21 22 23 |
# File 'app/models/tb_commerce/product_sku.rb', line 21 def price return product.price + add_price end |