Sha256: c2faa6f644622b5bcf7541143f415eb9cfcc65eca3bcb5c14e1a51dfcbe74b5d
Contents?: true
Size: 879 Bytes
Versions: 2
Compression:
Stored size: 879 Bytes
Contents
# frozen_string_literal: true module Transproc # Transformation functions for Procs # # @example # require 'ostruct' # require 'transproc/proc' # # include Transproc::Helper # # fn = t( # :map_value, # 'foo_bar', # t(:bind, OpenStruct.new(prefix: 'foo'), -> s { [prefix, s].join('_') }) # ) # # fn["foo_bar" => "bar"] # # => {"foo_bar" => "foo_bar"} # # @api public module ProcTransformations extend Registry # Change the binding for the given function # # @example # Transproc( # :bind, # OpenStruct.new(prefix: 'foo'), # -> s { [prefix, s].join('_') } # )['bar'] # # => "foo_bar" # # @param [Proc] # # @return [Proc] # # @api public def self.bind(value, binding, fn) binding.instance_exec(value, &fn) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
transproc-1.1.1 | lib/transproc/proc.rb |
transproc-1.1.0 | lib/transproc/proc.rb |