README.md in grab-0.0.1 vs README.md in grab-0.0.2
- old
+ new
@@ -1,22 +1,24 @@
# Grab
Grab provides an clean way to fetch multiple values from a hash. Instead of:
-```
-def my_method(opts)
- foo = opts.fetch(:foo)
- bar = opts.fetch(:bar)
-end
-```
+ def initialize(params)
+ foo = params.fetch(:foo)
+ bar = params.fetch(:bar)
+ end
you can write:
-```
-def my_method(opts)
- foo, bar = opts.grab(:foo, :bar)
-end
-```
+ def initialize(params)
+ foo, bar = params.grab(:foo, :bar)
+ end
+
+or if some of your params are optional:
+
+ def initialize(params)
+ foo, bar = params.values(:foo, :bar)
+ end
## Installation
Add this line to your application's Gemfile: