acts_as 0.6.3 → 0.6.4
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 +4 -4
- data/lib/acts_as/version.rb +1 -1
- data/lib/acts_as.rb +4 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15fd1734d96a4851b895c5dee27dee35f60527fc
|
4
|
+
data.tar.gz: bf3c25453ba178413ffbe423b9c31a833d454b91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3b38d53698a4b135a79869e55f8ffe940b0898fd1e70065870a60f7909cef90377b65111655f13cbeaf7bee2eec0616d3d92e9856d3286001192ff0d2a4e123
|
7
|
+
data.tar.gz: c6bbe641bc0b4265ba4100f8976855180d2f9e0503cffa5a3373483c94cf1cb4eafca7911e4be6bd8217dcf19d7c4ee3b9802d4cdf86475d7d4f2ef504b35560
|
data/lib/acts_as/version.rb
CHANGED
data/lib/acts_as.rb
CHANGED
@@ -18,7 +18,9 @@ module ActsAs
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def update_column(name, value)
|
21
|
-
if
|
21
|
+
if attribute_names.include?(name.to_s)
|
22
|
+
super
|
23
|
+
elsif (association = self.class.acts_as_fields.detect { |k,v| v.include?(name.to_s) }.try(:first)).present?
|
22
24
|
send(association).update_column name, value
|
23
25
|
else
|
24
26
|
super
|
@@ -101,23 +103,10 @@ module ActsAs
|
|
101
103
|
def whitelist_and_delegate_fields(association_class, one_association, prefix, with)
|
102
104
|
association_fields = association_class.columns.map(&:name) - PREFIX - prefix + with
|
103
105
|
|
104
|
-
build_prefix_methods(one_association, prefix)
|
105
|
-
|
106
106
|
delegate(*(association_fields + association_fields.map { |field| "#{field}=" }), to: one_association)
|
107
|
+
delegate(*(prefix + prefix.map { |field| "#{field}=" }), to: one_association, prefix: true)
|
107
108
|
|
108
109
|
acts_as_fields[one_association] = association_fields + prefix
|
109
110
|
end
|
110
|
-
|
111
|
-
def build_prefix_methods(one_association, prefix)
|
112
|
-
prefix.each do |field|
|
113
|
-
define_method("#{one_association}_#{field}") do |*args|
|
114
|
-
send(one_association).send(field, *args)
|
115
|
-
end
|
116
|
-
|
117
|
-
define_method("#{one_association}_#{field}=") do |*args|
|
118
|
-
send(one_association).send("#{field}=", *args)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
111
|
end
|
123
112
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hired, Inc
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.4.
|
124
|
+
rubygems_version: 2.4.5
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: delegate an entire 1:1 association worth of active record field-related helpers
|