property_sets 3.3.1 → 3.5.4
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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f4e1af4d793c11242f869c3c17e1d25044d301623d1a2f37570c522df9b3b2cf
|
4
|
+
data.tar.gz: 6001e124fb8cded395d58d07176a7ff39c14ce8c02e4f97b57a109f3bda0074b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91a32d9e89753106a977eb19637ca509b821e8630dcfbd882ef9ac648c6c9043f3dfab4feeb25fe192a946072940efaecf26a50cf014b8fec9ddd6d03ab81ef9
|
7
|
+
data.tar.gz: f498e7fab65d9fa4abbcbdce0ea16fe6051ea1d07d41504de521243d032cca7f75ca53c1f51550001fee2a27db43612c9d4869d1a6d86bbb46b18af88b28d805
|
@@ -158,26 +158,22 @@ module PropertySets
|
|
158
158
|
end
|
159
159
|
|
160
160
|
def association_class
|
161
|
-
@association_class ||=
|
162
|
-
if ActiveRecord::VERSION::STRING >= "3.1.0"
|
163
|
-
proxy_association.klass
|
164
|
-
else
|
165
|
-
@reflection.klass
|
166
|
-
end
|
167
|
-
end
|
161
|
+
@association_class ||= proxy_association.klass
|
168
162
|
end
|
169
163
|
end
|
170
164
|
|
171
165
|
module InstanceMethods
|
172
|
-
def
|
166
|
+
def update(attributes)
|
173
167
|
update_property_set_attributes(attributes)
|
174
168
|
super
|
175
169
|
end
|
170
|
+
alias update_attributes update
|
176
171
|
|
177
|
-
def
|
172
|
+
def update!(attributes)
|
178
173
|
update_property_set_attributes(attributes)
|
179
174
|
super
|
180
175
|
end
|
176
|
+
alias update_attributes! update!
|
181
177
|
|
182
178
|
def update_property_set_attributes(attributes)
|
183
179
|
if attributes && self.class.property_set_index.any?
|
@@ -188,6 +184,35 @@ module PropertySets
|
|
188
184
|
end
|
189
185
|
end
|
190
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
|
191
216
|
end
|
192
217
|
|
193
218
|
end
|
@@ -20,11 +20,27 @@ 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
|
+
@delegated_property_set_attributes ||= []
|
24
|
+
|
23
25
|
mappings.each do |old_attr, new_attr|
|
24
|
-
|
26
|
+
self.delegated_property_set_attributes << old_attr.to_s
|
27
|
+
if ActiveRecord.version < Gem::Version.new("5.0")
|
28
|
+
attribute old_attr, ActiveRecord::Type::Value.new
|
29
|
+
else
|
30
|
+
attribute old_attr, ActiveModel::Type::Value.new
|
31
|
+
end
|
32
|
+
define_method(old_attr) {
|
33
|
+
association = send(setname)
|
34
|
+
type = association.association_class.type(new_attr)
|
35
|
+
association.lookup_value(type, new_attr)
|
36
|
+
}
|
25
37
|
alias_method "#{old_attr}_before_type_cast", old_attr
|
26
38
|
define_method("#{old_attr}?") { send(setname).send("#{new_attr}?") }
|
27
|
-
define_method("#{old_attr}=")
|
39
|
+
define_method("#{old_attr}=") do |value|
|
40
|
+
attribute_will_change!(old_attr) if old_attr != value && !defined?(super)
|
41
|
+
send(setname).send("#{new_attr}=", value)
|
42
|
+
super(value) if defined?(super)
|
43
|
+
end
|
28
44
|
|
29
45
|
define_method("#{old_attr}_changed?") do
|
30
46
|
collection_proxy = send(setname)
|
@@ -40,6 +56,16 @@ module PropertySets
|
|
40
56
|
end
|
41
57
|
end
|
42
58
|
end
|
59
|
+
|
60
|
+
# These are not database columns and should not be included in queries but
|
61
|
+
# using the attributes API is the only way to track changes in the main model
|
62
|
+
if respond_to?(:user_provided_columns)
|
63
|
+
self.user_provided_columns.reject!{|k,_| @delegated_property_set_attributes.include?(k.to_s) }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def delegated_property_set_attributes
|
68
|
+
@delegated_property_set_attributes
|
43
69
|
end
|
44
70
|
end
|
45
71
|
end
|
@@ -105,7 +105,7 @@ module PropertySets
|
|
105
105
|
base.validate :validate_format_of_name
|
106
106
|
base.validate :validate_length_of_serialized_data
|
107
107
|
base.before_create :coerce_value
|
108
|
-
base.attr_accessible :name, :value if
|
108
|
+
base.attr_accessible :name, :value if defined?(ProtectedAttributes)
|
109
109
|
end
|
110
110
|
|
111
111
|
def property(key, options = nil)
|
@@ -137,8 +137,8 @@ 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
|
141
|
-
attr_accessible owner_class_key_sym, owner_class_sym if
|
140
|
+
validates_uniqueness_of :name, :scope => owner_class_key_sym, :case_sensitive => false
|
141
|
+
attr_accessible owner_class_key_sym, owner_class_sym if defined?(ProtectedAttributes)
|
142
142
|
end
|
143
143
|
|
144
144
|
def owner_assoc=(association)
|
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.4
|
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-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
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
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
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.6.
|
165
|
+
rubygems_version: 2.7.6.2
|
166
166
|
signing_key:
|
167
167
|
specification_version: 4
|
168
168
|
summary: Property sets for ActiveRecord.
|