remote_attr_accessor 0.0.2 → 0.0.3

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: c2ede50a3f49ede60794345478ccdf8ae51bb14d
4
- data.tar.gz: ebcf8f910e190836359c9d115acda6b6d1a1bea7
3
+ metadata.gz: 6c9e77b105bf43e3eb9d7db23a1edaf103a9a457
4
+ data.tar.gz: 3f7a4f9e08ab6369ee791e946adb2775d1f558f9
5
5
  SHA512:
6
- metadata.gz: 312503be03d1efa02fcee4fc7827345f3d098ff02b7ca2b14d9d654869f8496f88c974b30404a502976d5115d537b6ee9b213a0e76a41b1f57a51eaffec24a16
7
- data.tar.gz: 28d6a5f4e18b40e799bba2e81d2423d6c376924a0f0643e55f2d29199c22e5647bfd278478bda0baf257fba51c31b4c44c4c93370cd4e0801389e67f22c06742
6
+ metadata.gz: 674d0ef018e16f5109be528288ae05a60b967bf21fa9858cbfb322fc9d042896f69e994d4db74813b7c0cbe99e04eaaed6306ed8a16809619b6d7a9af759558e
7
+ data.tar.gz: 1c51a069192b2e90e336b1d459ef12a9ddbc65e4ec78255a69c27771dec656f43701da9a0ef3f99765008b269e9dd46f9fd03189c72127eed6af3a38b115d986
@@ -1,6 +1,8 @@
1
1
  module RemoteAttrAccessor
2
2
  end
3
3
 
4
+ require 'active_support'
5
+ require 'active_support/core_ext'
4
6
  require_relative 'remote_attr_accessor/version'
5
7
  require_relative 'remote_attr_accessor/config'
6
8
  require_relative 'remote_attr_accessor/base'
@@ -1,6 +1,10 @@
1
1
  module RemoteAttrAccessor
2
2
  # Override by lib/remote_attr_accessor/api.rb
3
3
  class Api
4
+ def self.get_remote_attrs_with_indifferent_access(ids)
5
+ get_remote_attrs(ids).with_indifferent_access
6
+ end
7
+
4
8
  def self.get_remote_attrs(ids)
5
9
  {}
6
10
  end
@@ -11,7 +11,7 @@ module RemoteAttrAccessor::Attrs
11
11
  eval("@#{attr_with_prefix}") ||
12
12
  instance_variable_set(
13
13
  "@#{attr_with_prefix}",
14
- RemoteAttrAccessor::Api.get_remote_attrs([remote_id])[config.remote_json_key][remote_id][attr.to_s]
14
+ RemoteAttrAccessor::Api.get_remote_attrs_with_indifferent_access([remote_id]).dig(config.remote_json_key, remote_id, attr.to_s)
15
15
  )
16
16
  end
17
17
 
@@ -12,11 +12,13 @@ module RemoteAttrAccessor::Bulk
12
12
  ids << locals.send(id_name)
13
13
  end
14
14
 
15
- remote_attrs_json = api.get_remote_attrs(ids)
15
+ remote_attrs_json = api.get_remote_attrs_with_indifferent_access(ids)
16
16
  return if remote_attrs_json == {}
17
17
  remote_attrs = remote_attrs_json[config.remote_json_key]
18
18
 
19
19
  ((locals.class == Array || locals.is_a?(ActiveRecord::Relation)) ? locals : [locals]).each do |local|
20
+ next unless remote_attrs.dig(local.send(id_name).to_s)
21
+
20
22
  ignored_attrs = [id_name.to_s, 'created_at', 'updated_at']
21
23
  (remote_attrs[local.send(id_name).to_s].keys - ignored_attrs).each do |rattr|
22
24
  attr_with_prefix = "@#{config.prefix}#{rattr}"
@@ -1,3 +1,3 @@
1
1
  module RemoteAttrAccessor
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_attr_accessor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-09 00:00:00.000000000 Z
11
+ date: 2016-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.2.0
27
27
  - !ruby/object:Gem::Dependency
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  version: '0'
77
77
  requirements: []
78
78
  rubyforge_project:
79
- rubygems_version: 2.4.5.1
79
+ rubygems_version: 2.5.1
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Remote Model Attribute Accessor.