### Hash Transformations: Key Manipulation Functions Source: https://context7.com/dry-rb/dry-transformer/llms.txt Provides examples of various key manipulation functions available in `Dry::Transformer::HashTransformations`, including symbolizing, stringifying, renaming, copying, accepting, and rejecting keys. ```ruby require 'dry/transformer/hash_transformations' H = Dry::Transformer::HashTransformations # symbolize_keys / stringify_keys H[:symbolize_keys].call("name" => "Jane", "age" => 30) # => { name: "Jane", age: 30 } H[:stringify_keys].call(name: "Jane", age: 30) # => { "name" => "Jane", "age" => 30 } # deep_symbolize_keys (recursive) H[:deep_symbolize_keys].call("user" => { "name" => "Jane", "roles" => [{ "id" => 1 }] }) # => { user: { name: "Jane", roles: [{ id: 1 }] } } # rename_keys H[:rename_keys, { user_name: :name, user_age: :age }].call(user_name: "Bob", user_age: 25) # => { name: "Bob", age: 25 } # copy_keys — original key is kept H[:copy_keys, { name: :full_name }].call(name: "Alice") # => { name: "Alice", full_name: "Alice" } # accept_keys / reject_keys H[:accept_keys, [:name]].call(name: "Jane", email: "jane@example.com", role: "admin") # => { name: "Jane" } H[:reject_keys, [:password, :token]].call(name: "Jane", password: "secret", token: "abc") ``` -------------------------------- ### Define Reusable Mappers with `Dry::Transformer::Pipe` Source: https://context7.com/dry-rb/dry-transformer/llms.txt Subclass `Dry::Transformer::Pipe` to create declarative, composable mapper classes using a DSL that mirrors registry function names. This example demonstrates transforming an array of raw data into an array of User Structs. ```ruby require 'dry/transformer' require 'dry/transformer/all' # loads all built-in transformation modules # Build a custom registry that includes all built-in modules module MyRegistry extend Dry::Transformer::Registry import Dry::Transformer::HashTransformations import Dry::Transformer::ArrayTransformations import Dry::Transformer::Coercions import Dry::Transformer::ClassTransformations end Address = Struct.new(:street, :city, :zipcode) User = Struct.new(:name, :email, :address) class UserMapper < Dry::Transformer::Pipe[MyRegistry] map_array do symbolize_keys rename_keys username: :name map_value :email, t(:to_string) nest :address, %i[street city zipcode] map_value :address do constructor_inject Address end constructor_inject User end end raw_data = [ { "username" => "jane_doe", "email" => :jane, "street" => "Main St", "city" => "NYC", "zipcode" => "10001" }, { "username" => "bob_smith","email" => :bob, "street" => "Oak Ave", "city" => "LA", "zipcode" => "90001" } ] UserMapper.new.call(raw_data) # => [ # #>, # #> # ] ``` -------------------------------- ### Registering and Using Custom Transformations Source: https://context7.com/dry-rb/dry-transformer/llms.txt Demonstrates how to extend a module to act as a transformation registry, register custom lambdas, and use module methods as functions. Shows retrieval, partial application, and composition. ```ruby require 'dry/transformer' module MyTransforms extend Dry::Transformer::Registry # Register a custom lambda register(:upcase_string, -> v { v.to_s.upcase }) # Define a module method directly def self.prefix(value, pfx) "#{pfx}_#{value}" end end # Retrieve as a Function object (args are curried) upcase = MyTransforms[:upcase_string] prefixer = MyTransforms[:prefix, "user"] upcase["hello"] # => "HELLO" prefixer["jane"] # => "user_jane" # Compose with >> into a pipeline pipeline = prefixer >> upcase pipeline["doe"] # => "USER_DOE" # Import from another registry module ExtendedTransforms extend Dry::Transformer::Registry import MyTransforms import :upcase_string, from: MyTransforms, as: :shout end ExtendedTransforms[:shout]["quiet"] # => "QUIET" ``` -------------------------------- ### Pipeline Composition with `>>` and `compose` Source: https://context7.com/dry-rb/dry-transformer/llms.txt Illustrates chaining `Function` objects using the `>>` operator (or `+`, `compose`) to create pipelines where the output of one function becomes the input of the next. Shows how to inspect the composed pipeline structure using `to_ast`. ```ruby require 'dry/transformer/hash_transformations' require 'dry/transformer/coercions' H = Dry::Transformer::HashTransformations step1 = H[:symbolize_keys] step2 = H[:reject_keys, [:internal_id]] step3 = H[:map_values, -> v { v.is_a?(String) ? v.strip : v }] pipeline = step1 >> step2 >> step3 pipeline.call( "name" => " Alice ", "age" => 30, "internal_id" => "secret-99" ) # => { name: "Alice", age: 30 } # to_ast gives a structured representation of the composed pipeline pipeline.to_ast # => [:symbolize_keys, [], [:reject_keys, [[:internal_id]]], [:map_values, [#]]] ``` -------------------------------- ### Top-level Function Constructor for Transformations Source: https://context7.com/dry-rb/dry-transformer/llms.txt Shows how to use the top-level `Dry::Transformer()` method as a shortcut to build `Function` objects from registered transformation symbols or callables. Demonstrates composing multiple transformations into a pipeline. ```ruby require 'dry/transformer/hash_transformations' require 'dry/transformer/array_transformations' # Build individual functions sym_keys = Dry::Transformer(:symbolize_keys) rename = Dry::Transformer(:rename_keys, user_name: :name) nest_addr = Dry::Transformer(:nest, :address, %i[street zipcode]) # Compose into a pipeline using >> pipeline = sym_keys >> rename >> nest_addr result = pipeline.call( "user_name" => "Jane", "street" => "Main St", "zipcode" => "10001" ) # => { name: "Jane", address: { street: "Main St", zipcode: "10001" } } ``` -------------------------------- ### Registry — extend Dry::Transformer::Registry Source: https://context7.com/dry-rb/dry-transformer/llms.txt Demonstrates how to extend a module with `Dry::Transformer::Registry` to create a transformation registry. This allows registering custom lambdas or methods, and importing functions from other registries. Retrieved functions are partially applied `Function` objects. ```APIDOC ## Registry — `extend Dry::Transformer::Registry` A mixin that turns any module into a transformation registry. Calling `registry[:fn_name, *args]` returns a partially-applied `Function` object. Custom registries can also register lambdas or import functions from other registries. ```ruby require 'dry/transformer' module MyTransforms extend Dry::Transformer::Registry # Register a custom lambda register(:upcase_string, -> v { v.to_s.upcase }) # Define a module method directly def self.prefix(value, pfx) "#{pfx}_#{value}" end end # Retrieve as a Function object (args are curried) upcase = MyTransforms[:upcase_string] prefixer = MyTransforms[:prefix, "user"] upcase["hello"] # => "HELLO" prefixer["jane"] # => "user_jane" # Compose with >> into a pipeline pipeline = prefixer >> upcase pipeline["doe"] # => "USER_DOE" # Import from another registry module ExtendedTransforms extend Dry::Transformer::Registry import MyTransforms import :upcase_string, from: MyTransforms, as: :shout end ExtendedTransforms[:shout]["quiet"] # => "QUIET" ``` ``` -------------------------------- ### Object Instantiation with Instance Variable Assignment Source: https://context7.com/dry-rb/dry-transformer/llms.txt Allocates an object instance and sets instance variables based on key-value pairs from the transformed hash. ```ruby require 'dry/transformer/class_transformations' class Config attr_reader :host, :port end obj = Dry::Transformer::ClassTransformations[:set_ivars, Config].call(host: "localhost", port: 5432) obj.host obj.port ``` -------------------------------- ### Object Instantiation with Constructor Injection Source: https://context7.com/dry-rb/dry-transformer/llms.txt Instantiates objects by passing transformed hash values as positional arguments to the constructor (.new). ```ruby require 'dry/transformer/class_transformations' Person = Struct.new(:name, :age) Dry::Transformer::ClassTransformations[:constructor_inject, Person].call("Jane", 30) ``` -------------------------------- ### Build a Full Pipeline: Raw Hash to Struct Source: https://context7.com/dry-rb/dry-transformer/llms.txt This pipeline transforms a raw hash by symbolizing keys, nesting specific keys into an 'address' hash, and then injecting that nested hash into an Address Struct. ```ruby require 'dry/transformer/array_transformations' Address = Struct.new(:city, :zipcode) pipeline = Dry::Transformer(:symbolize_keys) >> Dry::Transformer(:nest, :address, %i[city zipcode]) >> Dry::Transformer(:map_value, :address, Dry::Transformer::ClassTransformations[:constructor_inject, Address] ) pipeline.call("city" => "NYC", "zipcode" => "10001", "name" => "HQ") # => { name: "HQ", address: # } ``` -------------------------------- ### Execute Lambda in Context with `bind` Source: https://context7.com/dry-rb/dry-transformer/llms.txt Use `bind` to execute a lambda within the context of a given object, providing access to its instance variables and methods. This is useful for context-aware transformations within pipelines. ```ruby require 'dry/transformer/proc_transformations' require 'ostruct' context = OpenStruct.new(multiplier: 3) triple = Dry::Transformer::ProcTransformations[:bind, context, -> v { v * multiplier }] triple.call(7) # => 21 triple.call(10) # => 30 ``` ```ruby require 'dry/transformer/hash_transformations' formatter = OpenStruct.new(currency: "USD") format_price = Dry::Transformer(:bind, formatter, -> v { "#{currency} #{format('%.2f', v)}" }) Dry::Transformer(:map_value, :price, format_price).call(item: "Book", price: 12.5) # => { item: "Book", price: "USD 12.50" } ``` -------------------------------- ### Nest and Unwrap Hash Structures with Dry Transformer Source: https://context7.com/dry-rb/dry-transformer/llms.txt Use `nest` to group selected keys under a new parent key, and `unwrap` for the inverse operation. Both support key selection and prefix options for reshaping data. ```ruby require 'dry/transformer/hash_transformations' H = Dry::Transformer::HashTransformations # nest H[:nest, :address, %i[street city zipcode]].call( name: "Jane", street: "Main St", city: "NYC", zipcode: "10001" ) # => { name: "Jane", address: { street: "Main St", city: "NYC", zipcode: "10001" } } # unwrap — full collapse H[:unwrap, :address].call( name: "Jane", address: { street: "Main St", city: "NYC", zipcode: "10001" } ) # => { name: "Jane", street: "Main St", city: "NYC", zipcode: "10001" } # unwrap — selective keys only H[:unwrap, :address, [:city]].call( name: "Jane", address: { street: "Main St", city: "NYC" } ) # => { name: "Jane", city: "NYC", address: { street: "Main St" } } # unwrap with prefix option H[:unwrap, :address, prefix: true].call( address: { street: "Main St", city: "NYC" } ) # => { address_street: "Main St", address_city: "NYC" } # Compose nest + unwrap for reshaping pipeline = H[:symbolize_keys] >> H[:nest, :location, %i[lat lng]] pipeline.call("name" => "Place", "lat" => 40.7, "lng" => -74.0) # => { name: "Place", location: { lat: 40.7, lng: -74.0 } } ``` -------------------------------- ### Type Coercions with Dry::Transformer::Coercions Source: https://context7.com/dry-rb/dry-transformer/llms.txt Demonstrates various type coercion functions provided by Dry::Transformer::Coercions for converting values to common Ruby types. ```ruby require 'dry/transformer/coercions' C = Dry::Transformer::Coercions C[:to_string].call(42) C[:to_symbol].call("active") C[:to_integer].call("7") C[:to_float].call("3.14") C[:to_decimal].call(1.5) C[:to_boolean].call("true") C[:to_boolean].call("no") C[:to_boolean].call(1) C[:to_date].call("2024-06-15") C[:to_time].call("2024-06-15 09:00:00") C[:to_datetime].call("2024-06-15T09:00:00") ``` -------------------------------- ### HashTransformations — Key Manipulation Source: https://context7.com/dry-rb/dry-transformer/llms.txt The `Dry::Transformer::HashTransformations` module provides a set of functions specifically designed for manipulating hash keys. These include operations like symbolizing keys, stringifying keys, renaming keys, copying keys, and selectively accepting or rejecting keys based on a provided list. ```APIDOC ## HashTransformations — Key Manipulation `Dry::Transformer::HashTransformations` provides functions to transform hash keys: symbolize, stringify, rename, copy, reject, accept, and apply custom key mappings. ```ruby require 'dry/transformer/hash_transformations' H = Dry::Transformer::HashTransformations # symbolize_keys / stringify_keys H[:symbolize_keys].call("name" => "Jane", "age" => 30) # => { name: "Jane", age: 30 } H[:stringify_keys].call(name: "Jane", age: 30) # => { "name" => "Jane", "age" => 30 } # deep_symbolize_keys (recursive) H[:deep_symbolize_keys].call("user" => { "name" => "Jane", "roles" => [{ "id" => 1 }] }) # => { user: { name: "Jane", roles: [{ id: 1 }] } } # rename_keys H[:rename_keys, { user_name: :name, user_age: :age }].call(user_name: "Bob", user_age: 25) # => { name: "Bob", age: 25 } # copy_keys — original key is kept H[:copy_keys, { name: :full_name }].call(name: "Alice") # => { name: "Alice", full_name: "Alice" } # accept_keys / reject_keys H[:accept_keys, [:name]].call(name: "Jane", email: "jane@example.com", role: "admin") # => { name: "Jane" } H[:reject_keys, [:password, :token]].call(name: "Jane", password: "secret", token: "abc") # => { name: "Jane" } ``` ``` -------------------------------- ### Map Hash Keys and Values with Dry Transformer Source: https://context7.com/dry-rb/dry-transformer/llms.txt Use `map_keys` to transform hash keys using a custom function, and `map_values` to transform all hash values. `map_value` can be used to transform a single specific value. ```ruby require 'dry/transformer/hash_transformations' H = Dry::Transformer::HashTransformations # map_keys with a custom function H[:map_keys, -> k { k.to_s.upcase }].call(name: "Jane", age: 30) # => { "NAME" => "Jane", "AGE" => 30 } # map_values H[:map_values, -> v { v.to_s }].call(id: 1, score: 9.5) # => { id: "1", score: "9.5" } # map_value (single key) H[:map_value, :price, -> v { (v * 1.2).round(2) }].call(item: "book", price: 10.0) # => { item: "book", price: 12.0 } ``` -------------------------------- ### Map Array with Insert Key Source: https://context7.com/dry-rb/dry-transformer/llms.txt Applies a transformation to each element of an array, inserting a new key with a specified value. ```ruby require 'dry/transformer/array_transformations' A = Dry::Transformer::ArrayTransformations A[:insert_key, :name].call(["Alice", "Bob", nil]) ``` -------------------------------- ### Fold, Split, Eval Values, and Deep Merge Hashes with Dry Transformer Source: https://context7.com/dry-rb/dry-transformer/llms.txt Utilize `fold` to collapse an array of hashes to values from a single key, and `split` to expand a hash with a nested array into multiple hashes. `eval_values` evaluates proc values, and `deep_merge` combines hashes recursively. ```ruby require 'dry/transformer/hash_transformations' H = Dry::Transformer::HashTransformations # fold — collapse array of hashes to array of values from one key source = { name: "Jane", tasks: [{ title: "Write tests", priority: 1 }, { title: "Review PR" }] } H[:fold, :tasks, :title].call(source) # => { name: "Jane", tasks: ["Write tests", "Review PR"] } # split — expand one hash with nested array into multiple hashes grouped by key input = { name: "Joe", tasks: [ { title: "Sleep", priority: 1 }, { title: "Be nice", priority: 2 }, { title: "Exercise", priority: 2 } ] } H[:split, :tasks, [:priority]].call(input) # => [ # { name: "Joe", priority: 1, tasks: [{ title: "Sleep" }] }, # { name: "Joe", priority: 2, tasks: [{ title: "Be nice" }, { title: "Exercise" }] } # ] # eval_values — call proc values with supplied args template = { greeting: -> name { "Hello, #{name}!" }, farewell: -> name { "Bye, #{name}!" } } H[:eval_values, "Alice"].call(template) # => { greeting: "Hello, Alice!", farewell: "Bye, Alice!" } # eval_values with filter — only evaluate selected keys H[:eval_values, "Alice", [:greeting]].call(template) # => { greeting: "Hello, Alice!", farewell: # } # deep_merge base = { config: { timeout: 30, retries: 3 }, env: "production" } extra = { config: { retries: 5, debug: false }, version: "2.0" } H[:deep_merge].call(base, extra) # => { config: { timeout: 30, retries: 5, debug: false }, env: "production", version: "2.0" } ``` -------------------------------- ### Map, Wrap, Group, and Ungroup Arrays with Dry Transformer Source: https://context7.com/dry-rb/dry-transformer/llms.txt Use `map_array` to apply a function to each element, `wrap` to nest specified keys under a root key, and `group` to aggregate rows by shared keys. `ungroup` is the inverse of `group`. ```ruby require 'dry/transformer/array_transformations' require 'dry/transformer/hash_transformations' A = Dry::Transformer::ArrayTransformations # map_array — apply any function to each element A[:map_array, -> v { v * 2 }].call([1, 2, 3]) # => [2, 4, 6] # wrap — nest specified keys under a root key in each hash A[:wrap, :address, %i[city zipcode]].call([ { name: "Jane", city: "NYC", zipcode: "10001" }, { name: "Bob", city: "LA", zipcode: "90001" } ]) # => [ # { name: "Jane", address: { city: "NYC", zipcode: "10001" } }, # { name: "Bob", address: { city: "LA", zipcode: "90001" } } # ] # group — aggregate rows sharing the same root keys into a sub-array A[:group, :tags, [:tag]].call([ { article: "Ruby Tips", tag: "ruby" }, { article: "Ruby Tips", tag: "tips" }, { article: "Go Guide", tag: "go" } ]) # => [ # { article: "Ruby Tips", tags: [{ tag: "ruby" }, { tag: "tips" }] }, # { article: "Go Guide", tags: [{ tag: "go" }] } # ] # ungroup — inverse of group A[:ungroup, :tags, [:tag]].call([ { article: "Ruby Tips", tags: [{ tag: "ruby" }, { tag: "tips" }] } ]) # => [ # { article: "Ruby Tips", tag: "ruby" }, # { article: "Ruby Tips", tag: "tips" } # ] # extract_key / insert_key A[:extract_key, :name].call([{ name: "Alice" }, { name: "Bob" }, { role: "admin" }]) ``` -------------------------------- ### Compose Coercions with Hash Transformations Source: https://context7.com/dry-rb/dry-transformer/llms.txt Composes hash transformations with type coercions to process and convert specific fields within a hash. ```ruby require 'dry/transformer/coercions' require 'dry/transformer/hash_transformations' H = Dry::Transformer::HashTransformations C = Dry::Transformer::Coercions pipeline = H[:symbolize_keys] >> H[:map_value, :age, C[:to_integer]] >> H[:map_value, :active, C[:to_boolean]] pipeline.call({"age" => "25", "name" => "Jane", "active" => "yes"}) ``` -------------------------------- ### Type-Safe Guard with 'is' Source: https://context7.com/dry-rb/dry-transformer/llms.txt Provides a shorthand for type-safe guards, applying a transformation only if the value matches the specified type. ```ruby require 'dry/transformer/conditional' Cond = Dry::Transformer::Conditional upcase_arr = Cond[:is, Array, -> arr { arr.map(&:upcase) }] upcase_arr.call(["a", "b"]) upcase_arr.call("not array") ``` -------------------------------- ### Hash-Only Recursion with 'hash_recursion' Source: https://context7.com/dry-rb/dry-transformer/llms.txt Recursively applies a transformation function only to values that are hashes, traversing nested hash structures. ```ruby require 'dry/transformer/recursion' require 'dry/transformer/hash_transformations' R = Dry::Transformer::Recursion H = Dry::Transformer::HashTransformations R[:hash_recursion, H[:symbolize_keys]].call( "name" => "Jane", "address" => { "street" => "Main St", "zipcode" => "10001" } ) ``` -------------------------------- ### Map Array with Symbolize Keys Source: https://context7.com/dry-rb/dry-transformer/llms.txt Composes transformations to symbolize keys within each hash element of an array. ```ruby require 'dry/transformer/array_transformations' require 'dry/transformer/hash_transformations' pipeline = A[:map_array, Dry::Transformer::HashTransformations[:symbolize_keys]] pipeline.call([{"city" => "NYC"}, {"city" => "LA"}]) ``` -------------------------------- ### Conditional Transformation with Guard Source: https://context7.com/dry-rb/dry-transformer/llms.txt Applies a transformation function only if a given predicate returns true; otherwise, the value is passed through unchanged. ```ruby require 'dry/transformer/conditional' Cond = Dry::Transformer::Conditional to_sym = Cond[:guard, -> v { v.is_a?(String) }, -> v { v.to_sym }] [to_sym["hello"], to_sym[42], to_sym[:already]] ``` -------------------------------- ### Function#>> / Function#compose — Pipeline Composition Source: https://context7.com/dry-rb/dry-transformer/llms.txt Function objects in Dry Transformer support composition using the `>>` operator (or its aliases `+` and `compose`). This allows chaining transformations such that the output of the left transformation becomes the input for the right one. The result is a `Composite` object that can be further composed. ```APIDOC ## `Function#>>` / `Function#compose` — Pipeline Composition `Function` objects support `>>` (and its aliases `+` and `compose`) to chain two transformations so that the right side receives the output of the left side. Returns a `Composite` object that itself supports further composition. ```ruby require 'dry/transformer/hash_transformations' require 'dry/transformer/coercions' H = Dry::Transformer::HashTransformations step1 = H[:symbolize_keys] step2 = H[:reject_keys, [:internal_id]] step3 = H[:map_values, -> v { v.is_a?(String) ? v.strip : v }] pipeline = step1 >> step2 >> step3 pipeline.call( "name" => " Alice ", "age" => 30, "internal_id" => "secret-99" ) # => { name: "Alice", age: 30 } # to_ast gives a structured representation of the composed pipeline pipeline.to_ast # => [:symbolize_keys, [], [:reject_keys, [[:internal_id]]], [:map_values, [#]]] ``` ``` -------------------------------- ### Dry::Transformer() — Top-level Function Constructor Source: https://context7.com/dry-rb/dry-transformer/llms.txt The top-level `Dry::Transformer(name, *args)` method serves as a shorthand for creating a `Function` object from a registered transformation symbol or any callable object. It is functionally equivalent to calling `SomeRegistry[:name, *args]`. ```APIDOC ## `Dry::Transformer()` — Top-level Function Constructor The top-level `Dry::Transformer(name, *args)` method is shorthand for building a `Function` from any registered transformation symbol or callable. It is equivalent to `SomeRegistry[:name, *args]`. ```ruby require 'dry/transformer/hash_transformations' require 'dry/transformer/array_transformations' # Build individual functions sym_keys = Dry::Transformer(:symbolize_keys) rename = Dry::Transformer(:rename_keys, user_name: :name) nest_addr = Dry::Transformer(:nest, :address, %i[street zipcode]) # Compose into a pipeline using >> pipeline = sym_keys >> rename >> nest_addr result = pipeline.call( "user_name" => "Jane", "street" => "Main St", "zipcode" => "10001" ) # => { name: "Jane", address: { street: "Main St", zipcode: "10001" } } ``` ``` -------------------------------- ### Conditional Transformation in Map Array Source: https://context7.com/dry-rb/dry-transformer/llms.txt Uses a guard within a map_array pipeline to conditionally transform elements in an array, handling heterogeneous data types. ```ruby require 'dry/transformer/conditional' require 'dry/transformer/array_transformations' A = Dry::Transformer::ArrayTransformations Cond = Dry::Transformer::Conditional normalize = Cond[:guard, -> v { v.is_a?(String) }, -> v { v.strip.downcase }] A[:map_array, normalize].call([" Alice ", 42, " BOB ", nil]) ``` -------------------------------- ### Array-Only Recursion with 'array_recursion' Source: https://context7.com/dry-rb/dry-transformer/llms.txt Recursively applies a transformation function only to elements that are arrays, traversing nested array structures. ```ruby require 'dry/transformer/recursion' R = Dry::Transformer::Recursion R[:array_recursion, -> arr { arr.compact }].call( [["Alice", nil, "Bob"], ["Carol", nil]] ) ``` -------------------------------- ### Recursive Transformation with 'recursion' Source: https://context7.com/dry-rb/dry-transformer/llms.txt Applies a transformation function recursively through all enumerable elements (hashes and arrays) in a nested data structure. ```ruby require 'dry/transformer/recursion' require 'dry/transformer/hash_transformations' R = Dry::Transformer::Recursion H = Dry::Transformer::HashTransformations deep_data = { "id" => 1, "user" => { "name" => "Jane", "address" => { "city" => "NYC", "zip" => "10001" } }, "tags" => [{ "label" => "ruby" }, { "label" => "dry-rb" }] } sym_fn = Dry::Transformer(:is, Hash, H[:symbolize_keys]) R[:recursion, sym_fn].call(deep_data) ``` -------------------------------- ### Negate Predicate with 'not' Source: https://context7.com/dry-rb/dry-transformer/llms.txt Negates the result of a predicate function, useful for conditional transformations where a condition must not be met. ```ruby require 'dry/transformer/conditional' Cond = Dry::Transformer::Conditional is_string = Cond[:not, -> v { v.is_a?(Integer) }] is_string["hello"] is_string[42] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.