Skip to content

Commit 4b1bded

Browse files
authored
Allow prebuilt generators to get passed (#18)
* if acceptable type is a generator class, allow that to be passed * version bump
1 parent acccdcb commit 4b1bded

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/json_schematize/field_transformations.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ def transform_converter_type!
2020

2121
@converter = DEFAULT_CONVERTERS[@acceptable_types[0]]
2222
if @converter.nil?
23-
@converter = ->(val) { @acceptable_types[0].new(val) }
23+
@converter = Proc.new do |val|
24+
if @acceptable_types[0] < JsonSchematize::Generator && @acceptable_types[0] === val
25+
val
26+
else
27+
@acceptable_types[0].new(val)
28+
end
29+
end
2430
end
2531
end
2632

lib/json_schematize/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module JsonSchematize
4-
VERSION = "0.11.0"
4+
VERSION = "0.12.0"
55
end

0 commit comments

Comments
 (0)