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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67e684a0fd493690919a03ee753f5e028805d822
4
- data.tar.gz: 19d582b225116a7d35e859f060caaeb2d5d06efd
3
+ metadata.gz: 97a895fb24535f400ea8d29194014cc1839a70c4
4
+ data.tar.gz: 89f0e15d65ab2e4bf6185b050bdb50bccfa8af22
5
5
  SHA512:
6
- metadata.gz: 86d39e05a66b27082f4a6063f6ca57ac106da70bf7d945da71022498fb84ac18b1f6ef9fab87a93c453af80a9e29f8255d7eefa95ef803d73282e273ca6f364a
7
- data.tar.gz: 17a04b501f516948821fb4f720e7e2837c65f7906ac6032a54b7c361dc1a61d1e64b167dcac1e4297f9afcb75a5e056627516159cb8d303de08ea0e2fc1afd19
6
+ metadata.gz: 5853e1dd86267941c97ddbb948bb302f1a72c64c4d4b296465c1da318dd6796289eda87a563e8b811ffca8a5bd6fa05a49ae7f53370933052402bf78fef400f6
7
+ data.tar.gz: f4911345c74c394b58ff32359da4a378917fa0c01579a77a4d41059e489f68b2bd8c8c8876794e7aefeee370a1fe02be057e54f8fd10e3453c1a514725398c67
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Mappy
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mappy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Friesen