Module: SolidusProductAssembly::Spree::LineItemDecorator
- Defined in:
- app/decorators/models/solidus_product_assembly/spree/line_item_decorator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.prepended(base) ⇒ Object
6 7 8 9 10 |
# File 'app/decorators/models/solidus_product_assembly/spree/line_item_decorator.rb', line 6 def self.prepended(base) base.class_eval do scope :assemblies, -> { joins(product: :parts).distinct } end end |
Instance Method Details
#any_units_shipped? ⇒ Boolean
12 13 14 |
# File 'app/decorators/models/solidus_product_assembly/spree/line_item_decorator.rb', line 12 def any_units_shipped? inventory_units.any?(&:shipped?) end |
#quantity_by_variant ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/decorators/models/solidus_product_assembly/spree/line_item_decorator.rb', line 28 def quantity_by_variant if product.assembly? {}.tap { |hash| product.assemblies_parts.each { |ap| hash[ap.part] = ap.count * quantity } } else { variant => quantity } end end |