-
Notifications
You must be signed in to change notification settings - Fork 1
break a hash into a bunch of local variables.
License
dougp/shatter
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Shatter modifies method missing in its scope to allow for more convenient access to hash parameters as local variables (actually methods)
#old and verbose
#expecting :email, :password , and :id
def my_method(params={})
raise "No Email" unless params[:email]
raise "No Password" unles params[:password]
Record.find(params[:id])
end
#new and awesome
require 'shatter'
include 'Shatter'
#expecting :email, :password , and :id
def my_method(params={})
shatter(params) do
raise "No Email" unless email
raise "No Password" unless password
Record.find(id)
end
end
About
break a hash into a bunch of local variables.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published