Sha256: bf97075deb7bad65c8180ff15d15d3c0b6e05c5b969a9eb799a8fd30580211be
Contents?: true
Size: 791 Bytes
Versions: 3
Compression:
Stored size: 791 Bytes
Contents
module LazyResource class ResourceQueue include LazyResource::UrlGeneration def initialize @queue = [] end def queue(relation) @queue.push(relation) end def flush! @queue = [] end def request_queue Thread.current[:request_queue] ||= Typhoeus::Hydra.new end def run send_to_request_queue! request_queue.run end def send_to_request_queue! while(relation = @queue.pop) request = Request.new(url_for(relation), relation, :headers => relation.headers) request_queue.queue(request) end end def url_for(relation) url = '' url << relation.klass.site url << self.class.collection_path(relation.to_params, nil, relation.from) url end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lazy_resource-0.4.0 | lib/lazy_resource/resource_queue.rb |
lazy_resource-0.3.3 | lib/lazy_resource/resource_queue.rb |
lazy_resource-0.3.2 | lib/lazy_resource/resource_queue.rb |