Module: WebPipe::DSL::InstanceMethods Private
- Defined in:
- lib/web_pipe/dsl/instance_methods.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance methods for the pipe.
It is from here that you get the rack application you can route
to. The initialization phase gives you the chance to inject any
of the plugs or middlewares, while the instance you get has the
#call method expected by rack.
The pipe state can be accessed through the pipe class, which has been configured through ClassContext.
Constant Summary collapse
- EMPTY_INJECTIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
No injections at all.
{ plugs: Types::EMPTY_HASH, middlewares: Types::EMPTY_HASH }.freeze
- Injections =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Type for how plugs and middlewares should be injected.
Types::Strict::Hash.schema( plugs: Plug::Injections, middlewares: RackSupport::MiddlewareSpecification::Injections )
Instance Attribute Summary collapse
-
#injections ⇒ Object
readonly
private
has been configured.
-
#injections [Injections[]]([Injections[]]) ⇒ Object
readonly
Injected plugs and middlewares that allow overriding what.
- #middlewares ⇒ Array<RackSupport::Middlewares> readonly private
- #operations ⇒ ConnSupport::Composition::Operation[] readonly private
- #rack_app ⇒ RackSupport::AppWithMiddlewares[] readonly private
Instance Method Summary collapse
-
#call(env) ⇒ Array
private
Expected interface for rack.
-
#initialize(injects = EMPTY_INJECTIONS) ⇒ Object
private
rubocop:disable Metrics/AbcSize.
-
#to_proc ⇒ Object
private
Proc for the composition of all operations.
Instance Attribute Details
#injections ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
has been configured.
40 41 42 |
# File 'lib/web_pipe/dsl/instance_methods.rb', line 40 def injections @injections end |
#injections [Injections[]]([Injections[]]) ⇒ Object (readonly)
Injected plugs and middlewares that allow overriding what
40 |
# File 'lib/web_pipe/dsl/instance_methods.rb', line 40 attr_reader :injections |
#middlewares ⇒ Array<RackSupport::Middlewares> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'lib/web_pipe/dsl/instance_methods.rb', line 49 def middlewares @middlewares end |
#operations ⇒ ConnSupport::Composition::Operation[] (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 |
# File 'lib/web_pipe/dsl/instance_methods.rb', line 46 def operations @operations end |
#rack_app ⇒ RackSupport::AppWithMiddlewares[] (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 |
# File 'lib/web_pipe/dsl/instance_methods.rb', line 43 def rack_app @rack_app end |
Instance Method Details
#call(env) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Expected interface for rack.
71 72 73 |
# File 'lib/web_pipe/dsl/instance_methods.rb', line 71 def call(env) rack_app.call(env) end |
#initialize(injects = EMPTY_INJECTIONS) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rubocop:disable Metrics/AbcSize
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/web_pipe/dsl/instance_methods.rb', line 52 def initialize(injects = EMPTY_INJECTIONS) @injections = Injections[injects] container = self.class.container @middlewares = RackSupport::MiddlewareSpecification.inject_and_resolve( self.class.middleware_specifications, injections[:middlewares] ) @operations = Plug.inject_and_resolve( self.class.plugs, injections[:plugs], container, self ) app = App.new(operations) @rack_app = RackSupport::AppWithMiddlewares.new(middlewares, app) end |
#to_proc ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Proc for the composition of all operations.
This can be used to plug a WebPipe itself as an operation.
106 107 108 109 110 111 |
# File 'lib/web_pipe/dsl/instance_methods.rb', line 106 def to_proc ConnSupport::Composition .new(operations) .method(:call) .to_proc end |