Module: SolidusProductAssembly::Spree::VariantDecorator

Defined in:
app/decorators/models/solidus_product_assembly/spree/variant_decorator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



6
7
8
9
10
11
12
13
# File 'app/decorators/models/solidus_product_assembly/spree/variant_decorator.rb', line 6

def self.prepended(base)
  base.class_eval do
    has_and_belongs_to_many :assemblies,
      class_name: "Spree::Product",
      join_table: "spree_assemblies_parts",
      foreign_key: "part_id", association_foreign_key: "assembly_id"
  end
end

Instance Method Details

#assemblies_for(products) ⇒ Object



15
16
17
# File 'app/decorators/models/solidus_product_assembly/spree/variant_decorator.rb', line 15

def assemblies_for(products)
  assemblies.where(id: products)
end

#part?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/decorators/models/solidus_product_assembly/spree/variant_decorator.rb', line 19

def part?
  assemblies.exists?
end