Skip to content

Instantly share code, notes, and snippets.

@solnic
Created June 4, 2015 11:30
Show Gist options
  • Save solnic/e20a132d7f412eab7c6c to your computer and use it in GitHub Desktop.
Save solnic/e20a132d7f412eab7c6c to your computer and use it in GitHub Desktop.
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