portable-hole 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,10 +32,9 @@ module Reamaze
32
32
  class_eval <<-end_eval
33
33
  # Define the has_many relationship
34
34
  has_many :_#{eav},
35
- -> { where(context: '#{eav}') },
35
+ -> { where(context: '#{eav}').extending(AssociationExtensions) },
36
36
  :class_name => 'PortableValue',
37
37
  :as => :model,
38
- :extend => AssociationExtensions,
39
38
  :inverse_of => :model,
40
39
  :dependent => :delete_all
41
40
 
@@ -65,7 +64,7 @@ module Reamaze
65
64
  array << {:id => current.id, :key => k, :value => v}
66
65
  end
67
66
  else
68
- array << {:key => k, :value => v}
67
+ array << {:key => k, :value => v, :context => '#{eav}'}
69
68
  end
70
69
  end
71
70
 
@@ -94,7 +93,8 @@ module Reamaze
94
93
 
95
94
  if pref.blank?
96
95
  pref = prefs.build :key => name,
97
- :value => value
96
+ :value => value,
97
+ :context => preferential[1..-1]
98
98
  else
99
99
  pref.value = value
100
100
  end
@@ -2,7 +2,7 @@ class PortableValue < ActiveRecord::Base
2
2
  belongs_to :model, :polymorphic => true
3
3
  belongs_to :group, :polymorphic => true
4
4
 
5
- before_validation :set_group
5
+ before_save :set_group
6
6
 
7
7
  def set_group
8
8
  config = eval(self.model_type).eav_configuration
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: portable-hole
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lu Wang
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-09-22 00:00:00 Z
18
+ date: 2013-09-29 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails