Created
June 4, 2015 11:30
-
-
Save solnic/e20a132d7f412eab7c6c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'transproc' | |
include Transproc::Helper | |
def source_fn(source) | |
t(:add_keys, [:source]) >> t(:map_array, t(:map_value, :source, proc { source })) | |
end | |
fb_source = source_fn(:facebook) | |
tw_source = source_fn(:twitter) | |
puts fb_source.call([{ msg: 'Foo' }, { msg: 'Bar' }]).inspect | |
puts tw_source.call([{ msg: 'Foo' }, { msg: 'Bar' }]).inspect | |
# [{:source=>:facebook, :msg=>"Foo"}, {:source=>:facebook, :msg=>"Bar"}] | |
# [{:source=>:twitter, :msg=>"Foo"}, {:source=>:twitter, :msg=>"Bar"}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment