Skip to content

Instantly share code, notes, and snippets.

@pigoz
Created July 24, 2012 13:21
Show Gist options
  • Save pigoz/3169881 to your computer and use it in GitHub Desktop.
Save pigoz/3169881 to your computer and use it in GitHub Desktop.
little idea
mapper = mappy do
map :name => :username
imap :status => :invalid do |status|
status == invalid
end
end
map1 = mapper.new User, Hash
map2 = mapper.new Hash, User
user = map1.call(:name => "CiccioPasticcio", :status => "invalid")
hash = map2.call(User.new(:name => "Sbrodolino", :invalid => true))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment