File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,18 @@ Enable the helpers by requiring the `support` submodule:
191191require ' yake/support'
192192```
193193
194+ ` Array ` helpers:
195+
196+ ``` ruby
197+ array = [{ a: ' b' }, { a: ' c' }, { a: ' d' }]
198+
199+ array.pluck(:a )
200+ # => ["b", "c", "d"]
201+
202+ array.to_dynamodb
203+ # => {:L=>[{:a=>{:S=>"b"}}, {:a=>{:S=>"c"}}, {:a=>{:S=>"d"}}]}
204+ ```
205+
194206` Object ` helpers:
195207
196208``` ruby
Original file line number Diff line number Diff line change 66require 'uri'
77
88class Array
9+ def pluck ( key ) = map { |x | x [ key ] }
910 def to_dynamodb = { L : map ( &:to_dynamodb ) }
1011end
1112
Original file line number Diff line number Diff line change 7575 end
7676 end
7777
78+ context '#pluck' do
79+ it 'should return a list of the plucked values' do
80+ expect ( ( [ subject ] * 3 ) . pluck ( 'fizz' ) ) . to eq ( %w[ buzz ] * 3 )
81+ end
82+ end
83+
7884 context '#strict_encode64' do
7985 it 'should transform a Hash to a strict Base64-encoded string' do
8086 expect ( subject . strict_encode64 ) . to eq 'eyJmaXp6IjoiYnV6eiIsImphenoiOiJmdXp6IiwicmF6eiI6W3sibXRheiI6ImhhenoifV0sIndpenoiOnsia2l6eiI6ImthenoifX0='
You can’t perform that action at this time.
0 commit comments