Skip to content

Instantly share code, notes, and snippets.

@mbj
Created February 14, 2013 16:22
Show Gist options
  • Save mbj/4953930 to your computer and use it in GitHub Desktop.
Save mbj/4953930 to your computer and use it in GitHub Desktop.
Another ducktrap I use to assert hand written .yml files are not fucked up.
date_parser = Ducktrap.build do
primitive(String)
extern do
forward do |input|
Date.parse(input) || raise
end
inverse do |date|
raise
end
end
end
DUCKTRAP = Ducktrap.build do
collection do
attributes_hash_from_params_hash_extraction do
attribute_from_params_hash(:name)
attribute_from_params_hash(:start) do
add(date_parser)
end
attribute_from_params_hash(:end) do
add(date_parser)
end
attribute_from_params_hash(:location)
end
anima_from_attributes_hash(Event)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment