Class: Fetch::Base
Instance Method Summary collapse
-
#fetch ⇒ Object
Begin fetching.
-
#initialize(fetchable = nil) ⇒ Base
constructor
A new instance of Base.
Methods included from Callbacks
Constructor Details
#initialize(fetchable = nil) ⇒ Base
Returns a new instance of Base.
28 29 30 |
# File 'lib/fetch/base.rb', line 28 def initialize(fetchable = nil) @fetchable = fetchable end |
Instance Method Details
#fetch ⇒ Object
Begin fetching. Will run synchronous fetches first and async fetches afterwards. Updates progress when each module finishes its fetch.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fetch/base.rb', line 35 def fetch requests = instantiate_modules.select(&:fetch?).map(&:requests).flatten total, done = requests.size, 0 update_progress(total, done) before_fetch backend.new(requests).run do update_progress(total, done += 1) end after_fetch true rescue => e error(e) raise e end |