Class: WebPipe::Plug Private
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- WebPipe::Plug
- Defined in:
- lib/web_pipe/plug.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: InvalidPlugError
Constant Summary collapse
- Name =
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.
Types::Strict::Symbol.constructor(&:to_sym)
- Spec =
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.
Types.Interface(:call) | Types.Interface(:to_proc) | Types.Constant(nil) | Types::Strict::String | Types::Strict::Symbol
- 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.
Types::Strict::Hash.map( Name, Spec ).default(Types::EMPTY_HASH)
Class Method Summary collapse
-
.inject(plugs, injections) ⇒ Object
private
rubocop:enable Metrics/MethodLength rubocop:enable Metrics/AbcSize.
- .inject_plug(plug, injections) ⇒ Object private
Instance Method Summary collapse
-
#call(container, context) ⇒ Object
private
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize.
- #with(new_spec) ⇒ Object private
Class Method Details
.inject(plugs, 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:enable Metrics/MethodLength rubocop:enable Metrics/AbcSize
62 63 64 65 66 |
# File 'lib/web_pipe/plug.rb', line 62 def self.inject(plugs, injections) plugs.map do |plug| inject_plug(plug, injections) end end |
.inject_plug(plug, 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.
68 69 70 71 72 73 74 75 |
# File 'lib/web_pipe/plug.rb', line 68 def self.inject_plug(plug, injections) name = plug.name if injections.key?(name) plug.with(injections[name]) else plug end end |
Instance Method Details
#call(container, context) ⇒ 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/MethodLength rubocop:disable Metrics/AbcSize
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/web_pipe/plug.rb', line 46 def call(container, context) if spec.respond_to?(:to_proc) && !spec.is_a?(Symbol) spec.to_proc elsif spec.respond_to?(:call) spec elsif spec.nil? context.method(name) elsif container[spec] with(container[spec]).call(container, context) else raise InvalidPlugError, name end end |
#with(new_spec) ⇒ 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.
40 41 42 |
# File 'lib/web_pipe/plug.rb', line 40 def with(new_spec) new(spec: new_spec) end |