Skip to content

Instantly share code, notes, and snippets.

@lucasrenan
Created May 28, 2015 18:40
Show Gist options
  • Save lucasrenan/474234b0fbc0142377df to your computer and use it in GitHub Desktop.
Save lucasrenan/474234b0fbc0142377df to your computer and use it in GitHub Desktop.
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