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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8bafc9588ecb202ca2e69a4be628f030bfcc5e3
4
- data.tar.gz: b5b7505338e24c90ce1c2261bdc4033c8b5afa47
3
+ metadata.gz: c2ede50a3f49ede60794345478ccdf8ae51bb14d
4
+ data.tar.gz: ebcf8f910e190836359c9d115acda6b6d1a1bea7
5
5
  SHA512:
6
- metadata.gz: 001e11dd3ac987ef2d6f24de6463e8da8e4b68c54c41107ee0fadd2114744694de76567f9f7e594b8c724f461ef67ab4dcd6f9d1266dfa829a0569ae7358be7e
7
- data.tar.gz: 55d7c1fe45b97802231d086f6a8f7c739f0806e7347e51407aecb412448abfca6273a1b86355fa819039c7f93d099298c38913c11547c9143df8672de5c3809b
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[id_name]
9
+ ids << local.send(id_name)
10
10
  end
11
11
  elsif locals.is_a?(ActiveRecord::Base)
12
- ids << locals[id_name]
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 || Array) ? locals : [locals]).each do |local|
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[id_name].to_s].keys - ignored_attrs).each do |rattr|
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[id_name].to_s][rattr.to_s])
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
@@ -1,3 +1,3 @@
1
1
  module RemoteAttrAccessor
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  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.1
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-03 00:00:00.000000000 Z
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: {}