Created
January 4, 2018 00:40
-
-
Save jeremywadsack/b45bb85fb3d4e08f3c156ed447af2f9c to your computer and use it in GitHub Desktop.
Schema#load implementation suggestion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Schema | |
def load source | |
... | |
add_fields_to_schema(schema, source_fields) | |
self | |
end | |
def add_fields_to_schema schema, fields | |
fields.each do |field| | |
column = schema.send( | |
:add_field, | |
field["name"], | |
field["type"], | |
mode: field["mode"], | |
description: field["description"] | |
) | |
next unless field["type"] == "RECORD" | |
add_fields_to_schema(column, field["fields"]) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment