Sha256: 331d4d4fd70043179fb768bb524a91ba7952e42ec1d9c4b556b5c81f9527eeba
Contents?: true
Size: 998 Bytes
Versions: 4
Compression:
Stored size: 998 Bytes
Contents
# frozen_string_literal: true module Dry module Transformer # Transformation functions for Procs # # @example # require 'ostruct' # require 'dry/transformer/proc' # # include Dry::Transformer::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 # Dry::Transformer( # :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 end
Version data entries
4 entries across 4 versions & 1 rubygems