Last active
December 17, 2015 15:08
-
-
Save mbj/5629146 to your computer and use it in GitHub Desktop.
snusnu
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
require 'pp' | |
require 'ducktrap' | |
class Person | |
include Anima.new(:name) | |
end | |
SANITIZER = Ducktrap.build do | |
primitive(Hash) | |
hash_transform do | |
dump_key(:name) do | |
fetch_key('name') | |
primitive(String) | |
end | |
end | |
anima_load(Person) | |
end | |
result = SANITIZER.run('name' => 'John') | |
result.pretty_dump |
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
Ducktrap::Node::Block::Evaluator | |
input: {"name"=>"John"} | |
error | |
Ducktrap::Error | |
input: {"name"=>"John"} | |
context | |
Ducktrap::Node::Hash::Transform::Evaluator | |
input: {"name"=>"John"} | |
error | |
Ducktrap::Error | |
input: {"name"=>"John"} | |
context | |
Ducktrap::Node::Anima::Load::Evaluator | |
input: {"name"=>"John"} | |
error | |
Ducktrap::Error::Exception | |
input: {"name"=>"John"} | |
Anima::Error::Missing | |
exception: "Missing attribute(s) :name for Person" | |
context | |
Ducktrap::Node::Anima::Load | |
model: Person | |
context: | |
Ducktrap::Node::Anima::Load | |
model: Person | |
context: | |
Ducktrap::Node::Hash::Transform | |
body: | |
Ducktrap::Node::Key::Dump | |
key: :name | |
operand: | |
Ducktrap::Node::Block | |
body: | |
Ducktrap::Node::Key::Fetch | |
key: "name" | |
operand: | |
Ducktrap::Node::Noop | |
Ducktrap::Node::Primitive | |
primitive: String | |
Ducktrap::Node::Anima::Load | |
model: Person | |
context: | |
Ducktrap::Node::Block | |
body: | |
Ducktrap::Node::Primitive | |
primitive: Hash | |
Ducktrap::Node::Hash::Transform | |
body: | |
Ducktrap::Node::Key::Dump | |
key: :name | |
operand: | |
Ducktrap::Node::Block | |
body: | |
Ducktrap::Node::Key::Fetch | |
key: "name" | |
operand: | |
Ducktrap::Node::Noop | |
Ducktrap::Node::Primitive | |
primitive: String | |
Ducktrap::Node::Anima::Load | |
model: Person |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment