maestrano-connector-rails 0.3.2 → 0.3.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 +4 -4
- data/VERSION +1 -1
- data/app/models/maestrano/connector/rails/concerns/sub_entity_base.rb +1 -1
- data/lib/generators/connector/templates/complex_entity_example/contact.rb +4 -7
- data/lib/generators/connector/templates/complex_entity_example/lead.rb +4 -7
- data/lib/generators/connector/templates/complex_entity_example/lead_mapper.rb +5 -0
- data/lib/generators/connector/templates/complex_entity_example/person.rb +5 -9
- data/maestrano-connector-rails.gemspec +2 -2
- data/spec/models/sub_entity_base_spec.rb +30 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f35f9299a109e93d0c7028759a390d44dd7bff6c
|
4
|
+
data.tar.gz: 0e4695072a4fa120a03195bd405f459ff37025f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd0dff595ef6a407c615d2aa25f3ceb63a74416fece30e9f7332c00c964f991989ffb184b69537f910a662f941b7919750d4c2f75b8fcfcc47f2f80c0bbf47d9
|
7
|
+
data.tar.gz: d656df9663e232ec8f6c805353cffe338961d79c200e31ed2526ce8d3c0e6298fb4f9698543c7d8ebd91c2412645410ece0e4560ca57d235e38ca3700679bb6e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
@@ -86,7 +86,7 @@ module Maestrano::Connector::Rails::Concerns::SubEntityBase
|
|
86
86
|
if self.class.references[name]
|
87
87
|
self.class.references[name].each do |ref|
|
88
88
|
field = self.class.external? ? ref[:connec_field] : ref[:external_field]
|
89
|
-
ref_hash.merge! field.split('/').reverse.inject(Maestrano::Connector::Rails::Entity.id_from_ref(entity, ref,
|
89
|
+
ref_hash.merge! field.split('/').reverse.inject(Maestrano::Connector::Rails::Entity.id_from_ref(entity, ref, self.class.external?, organization)) { |a, n| { n.to_sym => a } }
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -11,13 +11,10 @@
|
|
11
11
|
# 'contact'
|
12
12
|
# end
|
13
13
|
|
14
|
-
# def
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
# else
|
19
|
-
# raise "Impossible mapping from #{self.class.entity_name} to #{name}"
|
20
|
-
# end
|
14
|
+
# def self.mapper_classes
|
15
|
+
# {
|
16
|
+
# 'person' => Entities::SubEntities::ContactMapper
|
17
|
+
# }
|
21
18
|
# end
|
22
19
|
|
23
20
|
# def self.object_name_from_connec_entity_hash(entity)
|
@@ -11,13 +11,10 @@
|
|
11
11
|
# 'lead'
|
12
12
|
# end
|
13
13
|
|
14
|
-
# def
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
# else
|
19
|
-
# raise "Impossible mapping from #{self.class.entity_name} to #{name}"
|
20
|
-
# end
|
14
|
+
# def self.mapper_classes
|
15
|
+
# {
|
16
|
+
# 'person' => Entities::SubEntities::LeadMapper
|
17
|
+
# }
|
21
18
|
# end
|
22
19
|
|
23
20
|
# def self.object_name_from_connec_entity_hash(entity)
|
@@ -4,6 +4,11 @@
|
|
4
4
|
# class Entities::SubEntities::LeadMapper
|
5
5
|
# extend HashMapper
|
6
6
|
|
7
|
+
# after_denormalize do |input, output|
|
8
|
+
# output[:is_lead] = true
|
9
|
+
# output
|
10
|
+
# end
|
11
|
+
|
7
12
|
# map from('title'), to('Salutation')
|
8
13
|
# map from('first_name'), to('FirstName')
|
9
14
|
# map from('last_name'), to('LastName'), default: 'Undefined'
|
@@ -10,15 +10,11 @@
|
|
10
10
|
# 'person'
|
11
11
|
# end
|
12
12
|
|
13
|
-
# def
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
# Enities::SubEntities::ContactMapper.normalize(entity)
|
19
|
-
# else
|
20
|
-
# raise "Impossible mapping from #{self.class.entity_name} to #{name}"
|
21
|
-
# end
|
13
|
+
# def self.mapper_classes
|
14
|
+
# {
|
15
|
+
# 'lead' => Entities::SubEntities::LeadMapper,
|
16
|
+
# 'contact' => Entities::SubEntities::ContactMapper,
|
17
|
+
# }
|
22
18
|
# end
|
23
19
|
|
24
20
|
# def self.object_name_from_connec_entity_hash(entity)
|
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: maestrano-connector-rails 0.3.
|
5
|
+
# stub: maestrano-connector-rails 0.3.3 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "maestrano-connector-rails"
|
9
|
-
s.version = "0.3.
|
9
|
+
s.version = "0.3.3"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -110,6 +110,8 @@ describe Maestrano::Connector::Rails::SubEntityBase do
|
|
110
110
|
}
|
111
111
|
end
|
112
112
|
end
|
113
|
+
|
114
|
+
it { expect(subject.mapper_classes).to eql({}) }
|
113
115
|
end
|
114
116
|
|
115
117
|
describe 'instance methods' do
|
@@ -132,6 +134,20 @@ describe Maestrano::Connector::Rails::SubEntityBase do
|
|
132
134
|
expect(AMapper).to receive(:denormalize).and_return({})
|
133
135
|
subject.map_to('Name', {}, nil)
|
134
136
|
end
|
137
|
+
|
138
|
+
context 'with references' do
|
139
|
+
let!(:organization) { create(:organization) }
|
140
|
+
let!(:idmap) { create(:idmap, organization: organization) }
|
141
|
+
before {
|
142
|
+
clazz = Maestrano::Connector::Rails::Entity
|
143
|
+
allow(clazz).to receive(:find_idmap).and_return(idmap)
|
144
|
+
allow(subject.class).to receive(:references).and_return({'Name' => [{reference_class: clazz, connec_field: 'organization_id', external_field: 'contact_id'}]})
|
145
|
+
}
|
146
|
+
|
147
|
+
it 'returns the mapped entity with its references' do
|
148
|
+
expect(subject.map_to('Name', {'contact_id' => idmap.external_id}, organization)).to eql({organization_id: idmap.connec_id})
|
149
|
+
end
|
150
|
+
end
|
135
151
|
end
|
136
152
|
context 'when not external' do
|
137
153
|
before {
|
@@ -142,6 +158,20 @@ describe Maestrano::Connector::Rails::SubEntityBase do
|
|
142
158
|
expect(AMapper).to receive(:normalize).and_return({})
|
143
159
|
subject.map_to('Name', {}, nil)
|
144
160
|
end
|
161
|
+
|
162
|
+
context 'with references' do
|
163
|
+
let!(:organization) { create(:organization) }
|
164
|
+
let!(:idmap) { create(:idmap, organization: organization) }
|
165
|
+
before {
|
166
|
+
clazz = Maestrano::Connector::Rails::Entity
|
167
|
+
allow(clazz).to receive(:find_idmap).and_return(idmap)
|
168
|
+
allow(subject.class).to receive(:references).and_return({'Name' => [{reference_class: clazz, connec_field: 'organization_id', external_field: 'contact_id'}]})
|
169
|
+
}
|
170
|
+
|
171
|
+
it 'returns the mapped entity with its references' do
|
172
|
+
expect(subject.map_to('Name', {'organization_id' => idmap.connec_id}, organization)).to eql({contact_id: idmap.external_id})
|
173
|
+
end
|
174
|
+
end
|
145
175
|
end
|
146
176
|
end
|
147
177
|
end
|