property_sets 3.4.0 → 3.5.5
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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7ec20448b7611d9a88bad99dd6054acb756b53b4a1245566140c1c69d9fddf83
|
|
4
|
+
data.tar.gz: 2f1f2ba401def86c3c0b417002c02f7242b44150d4f98ee329b0d0cc816d0030
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9da8220c3444cd8f71daafa64172bffcd17efb0f7b60b98ced8f4e8a5193ad7defbcbb8e13be1c914fc01c756c4f147316fe42af833e9edd85eb80032ff86144
|
|
7
|
+
data.tar.gz: 1e70f7eb188f60600ff770b5b0034e43de5575b471b88194b6c736d3eeabe13319c1281e65c6512ab12958e0c31079f4961fe0d1b976666ceccc12a1bbdbfd3b
|
|
@@ -163,15 +163,17 @@ module PropertySets
|
|
|
163
163
|
end
|
|
164
164
|
|
|
165
165
|
module InstanceMethods
|
|
166
|
-
def
|
|
166
|
+
def update(attributes)
|
|
167
167
|
update_property_set_attributes(attributes)
|
|
168
168
|
super
|
|
169
169
|
end
|
|
170
|
+
alias update_attributes update
|
|
170
171
|
|
|
171
|
-
def
|
|
172
|
+
def update!(attributes)
|
|
172
173
|
update_property_set_attributes(attributes)
|
|
173
174
|
super
|
|
174
175
|
end
|
|
176
|
+
alias update_attributes! update!
|
|
175
177
|
|
|
176
178
|
def update_property_set_attributes(attributes)
|
|
177
179
|
if attributes && self.class.property_set_index.any?
|
|
@@ -182,6 +184,35 @@ module PropertySets
|
|
|
182
184
|
end
|
|
183
185
|
end
|
|
184
186
|
end
|
|
187
|
+
|
|
188
|
+
def update_columns(attributes)
|
|
189
|
+
if delegated_property_sets?
|
|
190
|
+
attributes = attributes.reject{|k,_| self.class.delegated_property_set_attributes.include?(k.to_s) }
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
super attributes
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
private
|
|
197
|
+
|
|
198
|
+
def delegated_property_sets?
|
|
199
|
+
self.class.respond_to?(:delegated_property_set_attributes)
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def attributes_for_create(attribute_names)
|
|
203
|
+
super filter_delegated_property_set_attributes(attribute_names)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def attributes_for_update(attribute_names)
|
|
207
|
+
super filter_delegated_property_set_attributes(attribute_names)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def filter_delegated_property_set_attributes(attribute_names)
|
|
211
|
+
if delegated_property_sets?
|
|
212
|
+
return attribute_names - self.class.delegated_property_set_attributes.to_a
|
|
213
|
+
end
|
|
214
|
+
attribute_names
|
|
215
|
+
end
|
|
185
216
|
end
|
|
186
217
|
|
|
187
218
|
end
|
|
@@ -20,11 +20,30 @@ module PropertySets
|
|
|
20
20
|
def delegate_to_property_set(setname, mappings)
|
|
21
21
|
raise "Second argument must be a Hash" unless mappings.is_a?(Hash)
|
|
22
22
|
|
|
23
|
+
unless respond_to?(:delegated_property_set_attributes)
|
|
24
|
+
class_attribute :delegated_property_set_attributes
|
|
25
|
+
end
|
|
26
|
+
self.delegated_property_set_attributes ||= []
|
|
27
|
+
|
|
23
28
|
mappings.each do |old_attr, new_attr|
|
|
24
|
-
|
|
29
|
+
self.delegated_property_set_attributes << old_attr.to_s
|
|
30
|
+
if ActiveRecord.version < Gem::Version.new("5.0")
|
|
31
|
+
attribute old_attr, ActiveRecord::Type::Value.new
|
|
32
|
+
else
|
|
33
|
+
attribute old_attr, ActiveModel::Type::Value.new
|
|
34
|
+
end
|
|
35
|
+
define_method(old_attr) {
|
|
36
|
+
association = send(setname)
|
|
37
|
+
type = association.association_class.type(new_attr)
|
|
38
|
+
association.lookup_value(type, new_attr)
|
|
39
|
+
}
|
|
25
40
|
alias_method "#{old_attr}_before_type_cast", old_attr
|
|
26
41
|
define_method("#{old_attr}?") { send(setname).send("#{new_attr}?") }
|
|
27
|
-
define_method("#{old_attr}=")
|
|
42
|
+
define_method("#{old_attr}=") do |value|
|
|
43
|
+
attribute_will_change!(old_attr) if old_attr != value && !defined?(super)
|
|
44
|
+
send(setname).send("#{new_attr}=", value)
|
|
45
|
+
super(value) if defined?(super)
|
|
46
|
+
end
|
|
28
47
|
|
|
29
48
|
define_method("#{old_attr}_changed?") do
|
|
30
49
|
collection_proxy = send(setname)
|
|
@@ -40,6 +59,12 @@ module PropertySets
|
|
|
40
59
|
end
|
|
41
60
|
end
|
|
42
61
|
end
|
|
62
|
+
|
|
63
|
+
# These are not database columns and should not be included in queries but
|
|
64
|
+
# using the attributes API is the only way to track changes in the main model
|
|
65
|
+
if respond_to?(:user_provided_columns)
|
|
66
|
+
self.user_provided_columns.reject!{|k,_| delegated_property_set_attributes.include?(k.to_s) }
|
|
67
|
+
end
|
|
43
68
|
end
|
|
44
69
|
end
|
|
45
70
|
end
|
|
@@ -137,7 +137,7 @@ module PropertySets
|
|
|
137
137
|
@owner_class_sym = owner_class_name.underscore.to_sym
|
|
138
138
|
belongs_to owner_class_sym
|
|
139
139
|
validates_presence_of owner_class_sym
|
|
140
|
-
validates_uniqueness_of :name, :scope => owner_class_key_sym
|
|
140
|
+
validates_uniqueness_of :name, :scope => owner_class_key_sym, :case_sensitive => false
|
|
141
141
|
attr_accessible owner_class_key_sym, owner_class_sym if defined?(ProtectedAttributes)
|
|
142
142
|
end
|
|
143
143
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: property_sets
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.5.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Morten Primdahl
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-07-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -19,7 +19,7 @@ dependencies:
|
|
|
19
19
|
version: '4.2'
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '6.
|
|
22
|
+
version: '6.1'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -29,7 +29,7 @@ dependencies:
|
|
|
29
29
|
version: '4.2'
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '6.
|
|
32
|
+
version: '6.1'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: json
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -154,7 +154,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
154
154
|
requirements:
|
|
155
155
|
- - ">="
|
|
156
156
|
- !ruby/object:Gem::Version
|
|
157
|
-
version: '
|
|
157
|
+
version: '2.4'
|
|
158
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
requirements:
|
|
160
160
|
- - ">="
|
|
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
162
162
|
version: '0'
|
|
163
163
|
requirements: []
|
|
164
164
|
rubyforge_project:
|
|
165
|
-
rubygems_version: 2.7.6
|
|
165
|
+
rubygems_version: 2.7.6.2
|
|
166
166
|
signing_key:
|
|
167
167
|
specification_version: 4
|
|
168
168
|
summary: Property sets for ActiveRecord.
|