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
165 166 167 168 169 170 171 172 173 174 |
# File 'lib/sequel/extensions/concurrent_thread_pool.rb', line 165 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
154 155 156 157 158 159 160 161 162 163 |
# File 'lib/sequel/extensions/concurrent_thread_pool.rb', line 154 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
143 144 145 146 147 148 149 150 151 152 |
# File 'lib/sequel/extensions/concurrent_thread_pool.rb', line 143 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
180 181 182 |
# File 'lib/sequel/extensions/concurrent_thread_pool.rb', line 180 def async cached_dataset(:_async) { clone(async: true) } end |
#sync ⇒ Object
184 185 186 |
# File 'lib/sequel/extensions/concurrent_thread_pool.rb', line 184 def sync cached_dataset(:_sync) { clone(async: false) } end |