Class: Factbase::SyncQuery
- Inherits:
-
Object
- Object
- Factbase::SyncQuery
- Includes:
- Enumerable
- Defined in:
- lib/factbase/sync/sync_query.rb
Overview
Synchronized thread-safe query.
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2024-2025 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
-
#delete!(fb = @fb) ⇒ Integer
Delete all facts that match the query.
-
#each(fb = @fb, params = {}) {|Fact| ... } ⇒ Integer
Iterate facts one by one.
-
#initialize(origin, monitor, fb) ⇒ SyncQuery
constructor
Constructor.
-
#one(fb = @fb, params = {}) ⇒ String|Integer|Float|Time|Array|NilClass
Read a single value.
-
#to_s ⇒ Object
Turn it to a string.
Constructor Details
#initialize(origin, monitor, fb) ⇒ SyncQuery
Constructor.
19 20 21 22 23 |
# File 'lib/factbase/sync/sync_query.rb', line 19 def initialize(origin, monitor, fb) @origin = origin @monitor = monitor @fb = fb end |
Instance Method Details
#delete!(fb = @fb) ⇒ Integer
Delete all facts that match the query.
54 55 56 57 58 |
# File 'lib/factbase/sync/sync_query.rb', line 54 def delete!(fb = @fb) try_lock do @origin.delete!(fb) end end |
#each(fb = @fb, params = {}) {|Fact| ... } ⇒ Integer
Iterate facts one by one.
34 35 36 37 38 39 |
# File 'lib/factbase/sync/sync_query.rb', line 34 def each(fb = @fb, params = {}, &) return to_enum(__method__, fb, params) unless block_given? try_lock do @origin.each(fb, params, &) end end |
#one(fb = @fb, params = {}) ⇒ String|Integer|Float|Time|Array|NilClass
Read a single value.
45 46 47 48 49 |
# File 'lib/factbase/sync/sync_query.rb', line 45 def one(fb = @fb, params = {}) try_lock do @origin.one(fb, params) end end |
#to_s ⇒ Object
Turn it to a string.
26 27 28 |
# File 'lib/factbase/sync/sync_query.rb', line 26 def to_s @origin.to_s end |