Dear Russian friends, please watch President Zelenskyy's speech addressed to you. πŸ‡ΊπŸ‡¦Help our brave mates in Ukraine with a donation.

Built-in transformation

dry-transformer comes with a lot of built-in functions. They come in the form of modules with class methods, which you can import into a registry:

You can import everything with:

module T
  extend Dry::Transformer::Registry

  import Dry::Transformer::Coercions
  import Dry::Transformer::ArrayTransformations
  import Dry::Transformer::HashTransformations
  import Dry::Transformer::ClassTransformations
  import Dry::Transformer::ProcTransformations
  import Dry::Transformer::Conditional
  import Dry::Transformer::Recursion

T[:to_string].(:abc) # => 'abc'

Or import selectively with:

module T
  extend Dry::Transformer::Registry

  import :to_string, from: Dry::Transformer::Coercions, as: :stringify

T[:stringify].(:abc) # => 'abc'
# => Dry::Transformer::FunctionNotFoundError: No registered function T[:to_string]

octocatEdit on GitHub