Class: MonoVM::Whois::Transport::Middleware::Base
- Inherits:
-
Transport::Base
- Object
- Transport::Base
- MonoVM::Whois::Transport::Middleware::Base
- Defined in:
- lib/monovm/whois/transport/middleware/base.rb
Overview
Wraps another transport and forwards to it. Because it implements the same Base interface, layers compose in any order and nothing downstream can tell it is talking to a decorator.
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Class Method Summary collapse
-
.builder(**options) ⇒ Object
A lambda suitable for Factory's
middleware:list.
Instance Method Summary collapse
- #fetch(query:, endpoint:) ⇒ Object
-
#initialize(app) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
- #supports?(endpoint) ⇒ Boolean
-
#unwrap ⇒ Object
Reach the real transport through any stack of decorators.
Constructor Details
#initialize(app) ⇒ Base
Returns a new instance of Base.
30 31 32 33 |
# File 'lib/monovm/whois/transport/middleware/base.rb', line 30 def initialize(app) @app = app super() end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
19 20 21 |
# File 'lib/monovm/whois/transport/middleware/base.rb', line 19 def app @app end |
Class Method Details
.builder(**options) ⇒ Object
A lambda suitable for Factory's middleware: list.
Factory.new(middleware: [Middleware::Cache.builder(ttl: 300)])
25 26 27 |
# File 'lib/monovm/whois/transport/middleware/base.rb', line 25 def builder(**) ->(app) { new(app, **) } end |
Instance Method Details
#fetch(query:, endpoint:) ⇒ Object
35 36 37 |
# File 'lib/monovm/whois/transport/middleware/base.rb', line 35 def fetch(query:, endpoint:) app.fetch(query: query, endpoint: endpoint) end |
#inspect ⇒ Object
48 49 50 |
# File 'lib/monovm/whois/transport/middleware/base.rb', line 48 def inspect "#<#{self.class.name} -> #{app.inspect}>" end |
#supports?(endpoint) ⇒ Boolean
39 40 41 |
# File 'lib/monovm/whois/transport/middleware/base.rb', line 39 def supports?(endpoint) app.supports?(endpoint) end |
#unwrap ⇒ Object
Reach the real transport through any stack of decorators.
44 45 46 |
# File 'lib/monovm/whois/transport/middleware/base.rb', line 44 def unwrap app.is_a?(Base) ? app.unwrap : app end |