Skip to content

Commit

Permalink
Allow prebuilt generators to get passed (#18)
Browse files Browse the repository at this point in the history
* if acceptable type is a generator class, allow that to be passed

* version bump
  • Loading branch information
matt-taylor authored Feb 27, 2025
1 parent acccdcb commit 4b1bded
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/json_schematize/field_transformations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ def transform_converter_type!

@converter = DEFAULT_CONVERTERS[@acceptable_types[0]]
if @converter.nil?
@converter = ->(val) { @acceptable_types[0].new(val) }
@converter = Proc.new do |val|
if @acceptable_types[0] < JsonSchematize::Generator && @acceptable_types[0] === val
val
else
@acceptable_types[0].new(val)
end
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/json_schematize/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module JsonSchematize
VERSION = "0.11.0"
VERSION = "0.12.0"
end

0 comments on commit 4b1bded

Please sign in to comment.