piggybak_variants 0.1.0 → 0.1.1
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 974b650d16ee057bba72c9366c5d4b7942f1efc1
|
4
|
+
data.tar.gz: bf3f13b6c8fadce6fe36c9848feccfd01ba2f6ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e6191beaa9c9b397c01bc4ac02c34e6af43f985404e4f74d5f09b219acc7b366a47419e0c136a4026f4717a58ba08a1b1cbf1839549f8ecc47619441d368dbd
|
7
|
+
data.tar.gz: a7ce4b1db46fbc2fa48542266bede6e8a7f818c3602e69772668829ff5e64eb3d4e10df2c3d107005665914d6a1da5af3f03387b2be1ec0f826afd85b89dd00a
|
@@ -4,7 +4,7 @@ module PiggybakVariantsHelper
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def options_for_klass(klass)
|
7
|
-
options = ::PiggybakVariants::OptionConfiguration.
|
7
|
+
options = ::PiggybakVariants::OptionConfiguration.where(klass: klass).collect { |oc| oc.option }
|
8
8
|
end
|
9
9
|
|
10
10
|
def variant_map(object)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module PiggybakVariants
|
2
2
|
class Option < ActiveRecord::Base
|
3
|
-
has_many :option_values,
|
3
|
+
has_many :option_values, -> { order(:position) }, :dependent => :destroy
|
4
4
|
has_many :option_configurations, :dependent => :destroy
|
5
5
|
|
6
|
-
default_scope
|
6
|
+
default_scope { order('position ASC') }
|
7
7
|
|
8
8
|
accepts_nested_attributes_for :option_values, :allow_destroy => true
|
9
9
|
|
@@ -2,9 +2,9 @@ module PiggybakVariants
|
|
2
2
|
class Variant < ActiveRecord::Base
|
3
3
|
acts_as_sellable
|
4
4
|
belongs_to :item, :polymorphic => true
|
5
|
-
has_and_belongs_to_many :option_values
|
5
|
+
has_and_belongs_to_many :option_values, :class_name => "::PiggybakVariants::OptionValue"
|
6
6
|
|
7
|
-
scope :available, joins(:piggybak_sellable).where(["piggybak_sellables.active = ? AND (piggybak_sellables.quantity > 0 OR piggybak_sellables.unlimited_inventory = ?)",true,true])
|
7
|
+
scope :available, -> { joins(:piggybak_sellable).where(["piggybak_sellables.active = ? AND (piggybak_sellables.quantity > 0 OR piggybak_sellables.unlimited_inventory = ?)",true,true]) }
|
8
8
|
validate :option_value_validation
|
9
9
|
validate :require_item
|
10
10
|
|
@@ -20,7 +20,7 @@ module PiggybakVariants
|
|
20
20
|
# TODO: Add verification to prevent duplicate option value sets
|
21
21
|
|
22
22
|
klass = self.item.class
|
23
|
-
options = ::PiggybakVariants::OptionConfiguration.
|
23
|
+
options = ::PiggybakVariants::OptionConfiguration.where(klass: klass).collect { |oc| oc.option }
|
24
24
|
error = false
|
25
25
|
options.each do |option|
|
26
26
|
matching_option_values = self.option_values.select { |ov| ov.option == option }.size
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: piggybak_variants
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Case, Steph Skardal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Advanced variant support for Piggybak.
|
14
14
|
email:
|