Created
February 14, 2013 16:22
-
-
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.
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
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