Skip to content

Instantly share code, notes, and snippets.

@jeremywadsack
Created January 4, 2018 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremywadsack/b45bb85fb3d4e08f3c156ed447af2f9c to your computer and use it in GitHub Desktop.
Save jeremywadsack/b45bb85fb3d4e08f3c156ed447af2f9c to your computer and use it in GitHub Desktop.
Schema#load implementation suggestion
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