Skip to content

Instantly share code, notes, and snippets.

@cored
Created August 29, 2016 15:48
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 cored/f8f9118aa57f8ca8d25ab47cdcc31c85 to your computer and use it in GitHub Desktop.
Save cored/f8f9118aa57f8ca8d25ab47cdcc31c85 to your computer and use it in GitHub Desktop.
def node(input, *args)
if input.is_a?(::Symbol)
[type, [name, predicate(input, *args).to_ast]]
elsif input.respond_to?(:rule)
[type, [name, [:type, input]]]
elsif input.is_a?(::Class) && input < ::Dry::Struct
[type, [name, [:schema, Schema.create_class(self, input)]]]
elsif input.is_a?(Schema)
[type, [name, schema(input).to_ast]]
else
[type, [name, input.to_ast]]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment