Class: Factbase::Impatient::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/factbase/impatient.rb

Overview

Query decorator.

This is an internal class, it is not supposed to be instantiated directly.

Instance Method Summary collapse

Constructor Details

#initialize(term, maps, timeout, fb) ⇒ Query

Returns a new instance of Query.



47
48
49
50
51
52
# File 'lib/factbase/impatient.rb', line 47

def initialize(term, maps, timeout, fb)
  @term = term
  @maps = maps
  @timeout = timeout
  @fb = fb
end

Instance Method Details

#delete!(fb = @fb) ⇒ Object



78
79
80
81
82
# File 'lib/factbase/impatient.rb', line 78

def delete!(fb = @fb)
  impatient('delete!') do
    @fb.query(@term, @maps).delete!(fb)
  end
end

#each(fb = @fb, params = {}) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/factbase/impatient.rb', line 58

def each(fb = @fb, params = {}, &)
  a =
    impatient('each') do
      @fb.query(@term, @maps).each(fb, params).to_a
    end
  return a unless block_given?
  yielded = 0
  a.each do |f|
    yield f
    yielded += 1
  end
  yielded
end

#one(fb = @fb, params = {}) ⇒ Object



72
73
74
75
76
# File 'lib/factbase/impatient.rb', line 72

def one(fb = @fb, params = {})
  impatient('one') do
    @fb.query(@term, @maps).one(fb, params)
  end
end

#to_sObject



54
55
56
# File 'lib/factbase/impatient.rb', line 54

def to_s
  @term.to_s
end