Skip to content

Latest commit

 

History

History
21 lines (15 loc) · 847 Bytes

injecting_dependencies_through_dry_auto_inject.md

File metadata and controls

21 lines (15 loc) · 847 Bytes

Injecting dependencies through dry-auto_inject

web_pipe allows injecting plugs and middlewares at initialization time. As they are given as keyword arguments to the #initialize method, web_pipe is only compatible with the keyword argument strategy from dry-auto_inject. This is useful in the case you need to use other collaborator from your plugs' definitions.

WebPipe.load_extensions(:params)

class CreateUserApp
  include WebPipe
  include Deps[:create_user]
  
  plug :html, WebPipe::Plugs::ContentType.('text/html')
  plug :create
  
  private
  
  def create(conn)
    create_user.(conn.params)
  end
end