mappy 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mappy/configuration.rb +3 -1
- data/lib/mappy/version.rb +1 -1
- data/spec/lib/mappy/configuration_spec.rb +7 -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: 97a895fb24535f400ea8d29194014cc1839a70c4
|
4
|
+
data.tar.gz: 89f0e15d65ab2e4bf6185b050bdb50bccfa8af22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5853e1dd86267941c97ddbb948bb302f1a72c64c4d4b296465c1da318dd6796289eda87a563e8b811ffca8a5bd6fa05a49ae7f53370933052402bf78fef400f6
|
7
|
+
data.tar.gz: f4911345c74c394b58ff32359da4a378917fa0c01579a77a4d41059e489f68b2bd8c8c8876794e7aefeee370a1fe02be057e54f8fd10e3453c1a514725398c67
|
data/lib/mappy/configuration.rb
CHANGED
@@ -17,10 +17,12 @@ module Mappy
|
|
17
17
|
def map(source_instance, options = {})
|
18
18
|
target = options.fetch(:target)
|
19
19
|
target_builder_finder = options.fetch(:target_builder_finder) { Mappy::TargetBuilderFactory }
|
20
|
+
target_builder = target_builder_finder.call(target)
|
21
|
+
|
22
|
+
return source_instance if source_instance.is_a?(target_builder)
|
20
23
|
|
21
24
|
source_type = extract_source_type(source_instance)
|
22
25
|
legend = extract_legend(target, source_type)
|
23
|
-
target_builder = target_builder_finder.call(target)
|
24
26
|
|
25
27
|
resolve(source_instance, target_builder, legend)
|
26
28
|
end
|
data/lib/mappy/version.rb
CHANGED
@@ -30,6 +30,13 @@ module Mappy
|
|
30
30
|
document = subject.map(article, target: target_type, target_builder_finder: target_builder_finder)
|
31
31
|
expect(document.title).to eq(article.title)
|
32
32
|
end
|
33
|
+
|
34
|
+
it 'should return the source if source is already of target type' do
|
35
|
+
source = target_builder.new(title: 'Hello')
|
36
|
+
target_builder_finder.should_receive(:call).with(target_type).and_return(target_builder)
|
37
|
+
document = subject.map(source, target: target_type, target_builder_finder: target_builder_finder)
|
38
|
+
expect(document).to eq(source)
|
39
|
+
end
|
33
40
|
end
|
34
41
|
end
|
35
42
|
end
|