Class: Wayfarer::Middleware::Fetch
- Inherits:
-
Object
- Object
- Wayfarer::Middleware::Fetch
- Includes:
- Stage::API
- Defined in:
- lib/wayfarer/middleware/fetch.rb
Instance Attribute Summary collapse
-
#pool ⇒ Object
readonly
Returns the value of attribute pool.
-
#task ⇒ Object
Returns the value of attribute task.
Instance Method Summary collapse
- #call(task) ⇒ Object
-
#initialize ⇒ Fetch
constructor
A new instance of Fetch.
Methods included from Stage::API
Constructor Details
#initialize ⇒ Fetch
Returns a new instance of Fetch.
11 12 13 |
# File 'lib/wayfarer/middleware/fetch.rb', line 11 def initialize @pool = Wayfarer::Networking::Pool.instance end |
Instance Attribute Details
#pool ⇒ Object (readonly)
Returns the value of attribute pool.
8 9 10 |
# File 'lib/wayfarer/middleware/fetch.rb', line 8 def pool @pool end |
#task ⇒ Object
Returns the value of attribute task.
9 10 11 |
# File 'lib/wayfarer/middleware/fetch.rb', line 9 def task @task end |
Instance Method Details
#call(task) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/wayfarer/middleware/fetch.rb', line 15 def call(task) self.task = task pool.with do |adapter| task..adapter = adapter case result = adapter.fetch(task.url) when Networking::Result::Redirect stage(result.redirect_url) when Networking::Result::Success task..page = result.page yield if block_given? end end end |