flows icon indicating copy to clipboard operation
flows copied to clipboard

Change the behavior for Flows::Plugin::DependencyInjector

Open ddemirkhanyan-vineti opened this issue 4 years ago • 0 comments

Currently the approach for defining the dependency is not very comfortable when defining a not required dependency.

  dependency :my_dependency,
             default: DefaultDependency,
             type: MyType,
             required: false | true

When the dependency is not required you have to pass a default otherwise it will error out, which proved to be non-optimal when dependencies are so not required there is even no default implementation.

The correct way to handle this seems to be the following:

  • When dependency is required - you have to pass it, if there is no default - it will error out
  • When the dependency is not required - if it's not passed and there is no default just evaluate the variable to nil

That way we can have it more flexible.

ddemirkhanyan-vineti avatar Sep 23 '20 15:09 ddemirkhanyan-vineti