remote_attr_accessor 0.0.1 → 0.0.2
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/remote_attr_accessor/bulk.rb +6 -6
- data/lib/remote_attr_accessor/version.rb +1 -1
- 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: c2ede50a3f49ede60794345478ccdf8ae51bb14d
|
4
|
+
data.tar.gz: ebcf8f910e190836359c9d115acda6b6d1a1bea7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 312503be03d1efa02fcee4fc7827345f3d098ff02b7ca2b14d9d654869f8496f88c974b30404a502976d5115d537b6ee9b213a0e76a41b1f57a51eaffec24a16
|
7
|
+
data.tar.gz: 28d6a5f4e18b40e799bba2e81d2423d6c376924a0f0643e55f2d29199c22e5647bfd278478bda0baf257fba51c31b4c44c4c93370cd4e0801389e67f22c06742
|
@@ -4,23 +4,23 @@ module RemoteAttrAccessor::Bulk
|
|
4
4
|
def load_remote_attr(locals)
|
5
5
|
id_name = config.id_name
|
6
6
|
ids = Array.new
|
7
|
-
if locals.is_a?(ActiveRecord::Relation)
|
7
|
+
if locals.class == Array || locals.is_a?(ActiveRecord::Relation)
|
8
8
|
locals.each do |local|
|
9
|
-
ids << local
|
9
|
+
ids << local.send(id_name)
|
10
10
|
end
|
11
11
|
elsif locals.is_a?(ActiveRecord::Base)
|
12
|
-
ids << locals
|
12
|
+
ids << locals.send(id_name)
|
13
13
|
end
|
14
14
|
|
15
15
|
remote_attrs_json = api.get_remote_attrs(ids)
|
16
16
|
return if remote_attrs_json == {}
|
17
17
|
remote_attrs = remote_attrs_json[config.remote_json_key]
|
18
18
|
|
19
|
-
(locals.is_a?(ActiveRecord::Relation
|
19
|
+
((locals.class == Array || locals.is_a?(ActiveRecord::Relation)) ? locals : [locals]).each do |local|
|
20
20
|
ignored_attrs = [id_name.to_s, 'created_at', 'updated_at']
|
21
|
-
(remote_attrs[local
|
21
|
+
(remote_attrs[local.send(id_name).to_s].keys - ignored_attrs).each do |rattr|
|
22
22
|
attr_with_prefix = "@#{config.prefix}#{rattr}"
|
23
|
-
local.instance_variable_set(attr_with_prefix, remote_attrs[local
|
23
|
+
local.instance_variable_set(attr_with_prefix, remote_attrs[local.send(id_name).to_s][rattr.to_s])
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_attr_accessor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kenji.suzuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -56,7 +56,7 @@ files:
|
|
56
56
|
- lib/remote_attr_accessor/config.rb
|
57
57
|
- lib/remote_attr_accessor/version.rb
|
58
58
|
- lib/tasks/remote_attr_accessor_tasks.rake
|
59
|
-
homepage:
|
59
|
+
homepage: https://github.com/kenjiszk/remote_attr_accessor
|
60
60
|
licenses:
|
61
61
|
- MIT
|
62
62
|
metadata: {}
|