restforce-db 1.2.11 → 1.2.12
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/restforce/db/associations/belongs_to.rb +24 -2
- data/lib/restforce/db/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54e87c10756c3eaa8d5a1307477ab6bcbe3743eb
|
4
|
+
data.tar.gz: 281164ea7eaaca49f8b2867b85232634fa63e326
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84649d0104478df05e9e1d4664781757a2a68f3e067861c25093f0a4df31c1587121648a57d4bcf8a992b1d8d7ad52702efbbc236fc87650ee7983f8ccf76c1d
|
7
|
+
data.tar.gz: 00509806871db7f6fb9046232882d7dd2564b72c6b541b1b73bd2f5f2af763ca47e2cc07001e51774fde2e50920a569fc1dbefa8d3d3ca6a4aed90c0cea266af
|
@@ -25,7 +25,7 @@ module Restforce
|
|
25
25
|
instances = []
|
26
26
|
|
27
27
|
for_mappings(database_record) do |mapping, lookup|
|
28
|
-
lookup_id = salesforce_record
|
28
|
+
lookup_id = deep_lookup(salesforce_record, lookup)
|
29
29
|
lookups[mapping.lookup_column] = lookup_id
|
30
30
|
instance = mapping.salesforce_record_type.find(lookup_id)
|
31
31
|
|
@@ -97,7 +97,29 @@ module Restforce
|
|
97
97
|
inverse_association = association_for(reflection)
|
98
98
|
|
99
99
|
salesforce_instance = instance.mapping.salesforce_record_type.find(instance.id)
|
100
|
-
salesforce_instance.record
|
100
|
+
deep_lookup(salesforce_instance.record, inverse_association.lookup) if salesforce_instance
|
101
|
+
end
|
102
|
+
|
103
|
+
# Internal: Get the value for a potentially nested lookup field.
|
104
|
+
#
|
105
|
+
# salesforce_record - A Hashie::Mash representing a Salesforce object.
|
106
|
+
# lookup - A String value lookup.
|
107
|
+
#
|
108
|
+
# Example:
|
109
|
+
#
|
110
|
+
# hash = { "Name" => "Chaplin", "Address_r" => { "City" => "Berlin" } }
|
111
|
+
#
|
112
|
+
# deep_lookup(hash, "Name")
|
113
|
+
# # => "Chaplin"
|
114
|
+
#
|
115
|
+
# deep_lookup(hash, "Address_r.City")
|
116
|
+
# # => "Berlin"
|
117
|
+
#
|
118
|
+
# Returns the value of the nested key.
|
119
|
+
def deep_lookup(salesforce_record, lookup)
|
120
|
+
lookup.split(".").inject(salesforce_record) do |hash, key|
|
121
|
+
hash[key]
|
122
|
+
end
|
101
123
|
end
|
102
124
|
|
103
125
|
end
|
data/lib/restforce/db/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restforce-db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Horner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|