Module: Database::ConcurrentThreadPool::DatasetMethods
- Defined in:
- lib/sequel/extensions/concurrent_thread_pool.rb
Class Method Summary collapse
- .define_async_args_or_block_method(mod, method) ⇒ Object
- .define_async_block_method(mod, method) ⇒ Object
- .define_async_method(mod, method) ⇒ Object
Instance Method Summary collapse
Class Method Details
.define_async_args_or_block_method(mod, method) ⇒ Object
173 174 175 176 177 178 179 180 181 182 |
# File 'lib/sequel/extensions/concurrent_thread_pool.rb', line 173 def self.define_async_args_or_block_method(mod, method) mod.send(:define_method, method) do |*args, &block| if (block || !args.empty?) && @opts[:async] ds = sync db.send(:async_run) { ds.send(method, *args, &block) } else super(*args, &block) end end end |
.define_async_block_method(mod, method) ⇒ Object
162 163 164 165 166 167 168 169 170 171 |
# File 'lib/sequel/extensions/concurrent_thread_pool.rb', line 162 def self.define_async_block_method(mod, method) mod.send(:define_method, method) do |*args, &block| if block && @opts[:async] ds = sync db.send(:async_run) { ds.send(method, *args, &block) } else super(*args, &block) end end end |
.define_async_method(mod, method) ⇒ Object
151 152 153 154 155 156 157 158 159 160 |
# File 'lib/sequel/extensions/concurrent_thread_pool.rb', line 151 def self.define_async_method(mod, method) mod.send(:define_method, method) do |*args, &block| if @opts[:async] ds = sync db.send(:async_run) { ds.send(method, *args, &block) } else super(*args, &block) end end end |
Instance Method Details
#async ⇒ Object
188 189 190 |
# File 'lib/sequel/extensions/concurrent_thread_pool.rb', line 188 def async cached_dataset(:_async) { clone(async: true) } end |
#sync ⇒ Object
192 193 194 |
# File 'lib/sequel/extensions/concurrent_thread_pool.rb', line 192 def sync cached_dataset(:_sync) { clone(async: false) } end |