Class: Factbase::SyncQuery
- Inherits:
-
Object
- Object
- Factbase::SyncQuery
- Defined in:
- lib/factbase/sync/sync_query.rb
Overview
Synchronized thread-safe query.
- Author
-
Yegor Bugayenko (yegor256@gmail.com)
- 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, mutex, fb) ⇒ SyncQuery
constructor
Constructor.
-
#one(fb = @fb, params = {}) ⇒ String|Integer|Float|Time|Array|NilClass
Read a single value.
Constructor Details
#initialize(origin, mutex, fb) ⇒ SyncQuery
Constructor.
17 18 19 20 21 |
# File 'lib/factbase/sync/sync_query.rb', line 17 def initialize(origin, mutex, fb) @origin = origin @mutex = mutex @fb = fb end |
Instance Method Details
#delete!(fb = @fb) ⇒ Integer
Delete all facts that match the query.
47 48 49 50 51 |
# File 'lib/factbase/sync/sync_query.rb', line 47 def delete!(fb = @fb) try_lock do @origin.delete!(fb) end end |
#each(fb = @fb, params = {}) {|Fact| ... } ⇒ Integer
Iterate facts one by one.
27 28 29 30 31 32 |
# File 'lib/factbase/sync/sync_query.rb', line 27 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.
38 39 40 41 42 |
# File 'lib/factbase/sync/sync_query.rb', line 38 def one(fb = @fb, params = {}) try_lock do @origin.one(fb, params) end end |