You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide an example in the user documentation for short pipe definition + provide helper function to make it possible.
Dry::Transformer introduced the idea of wrapping transformation into classes, which I really like. The new syntax with nested block of code is much more readable than the original one with function composition .>>. The problem I see in the new syntax, is the fact that you have to define a new class for each complex transformation. I know the rationale for that, but this seems awkward.
I would suggest a simple helper function in the Pipe class, that would make the code more rubish.
Examples
Let's assume we have the following module and a class:
The module is defined as an entry point for user-defined, global transformations.
The class is defined as a base class for all user-defined pipes. At present defining a new complex transformation requires the following code:
As a result it is easier to define new conversions as methods in the local context.
I suggest make! was defined in the Dry::Transoformer::Pipe, so we won't have to define it.
Alternatively current implementation of define! could be changed to allow the syntax introduced by make!.
The text was updated successfully, but these errors were encountered:
Provide an example in the user documentation for short pipe definition + provide helper function to make it possible.
Dry::Transformer
introduced the idea of wrapping transformation into classes, which I really like. The new syntax with nested block of code is much more readable than the original one with function composition.>>
. The problem I see in the new syntax, is the fact that you have to define a new class for each complex transformation. I know the rationale for that, but this seems awkward.I would suggest a simple helper function in the
Pipe
class, that would make the code more rubish.Examples
Let's assume we have the following module and a class:
The module is defined as an entry point for user-defined, global transformations.
The class is defined as a base class for all user-defined pipes. At present defining a new complex transformation requires the following code:
The anonymous class is used to avoid namespace pollution, but the code seems awkward.
We can make it look better with the following definition of TPipe:
The converter then looks as follows:
As a result it is easier to define new conversions as methods in the local context.
I suggest
make!
was defined in theDry::Transoformer::Pipe
, so we won't have to define it.Alternatively current implementation of
define!
could be changed to allow the syntax introduced bymake!
.The text was updated successfully, but these errors were encountered: