Created
May 28, 2015 18:40
-
-
Save lucasrenan/474234b0fbc0142377df to your computer and use it in GitHub Desktop.
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
def products_path | |
"/products" | |
end | |
def product_path(id) | |
"/products/#{id}" | |
end | |
def dic | |
{ | |
created: -> (id) { product_path(id) }, | |
deleted: -> { products_path } | |
} | |
end | |
puts dic.inspect # => {:created=>#<Proc:[email protected]:11 (lambda)>, :deleted=>#<Proc:[email protected]:12 (lambda)>} | |
puts dic[:created].call(1) # => /products/1 | |
puts dic[:deleted].call # => /products |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment