Last active
April 22, 2016 20:07
-
-
Save gary/7f0fbc067b3c127209d27323ddfaab41 to your computer and use it in GitHub Desktop.
#map invocation wtf
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
open(url) { |channel| JSON.parse(channel.read) }.map do |channel_data| | |
attrs = channel_data.values_at("id", "key", "name", "description", | |
"asset_url", "created_at", "updated_at") | |
Channel.new(*attrs).tap(&:pick_stream_url) | |
end | |
# => #<Enumerator: [{"json"=>"attrs"}, { "json"=> "attrs"},{"json"=>"attrs"}]:map> | |
open(url) { |channel| JSON.parse(channel.read) }.map { |channel_data| | |
attrs = channel_data.values_at("id", "key", "name", "description", | |
"asset_url", "created_at", "updated_at") | |
Channel.new(*attrs).tap(&:pick_stream_url) | |
} | |
# => [#<Channel:0x007ff7b388ecc8>, #<Channel:0x007ff7b38e2508>, #<Channel:0x007ff7b2a38048>] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment