Module: Beanstalker::Extensions
- Defined in:
- lib/beanstalker/queue.rb,
lib/beanstalker/extend.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #async_send(selector, *args) ⇒ Object
- #async_send_opts(selector, opts, *args) ⇒ Object
- #interpolate_async_options(options, object, *args) ⇒ Object
- #rrepr ⇒ Object
Class Method Details
.included(receiver) ⇒ Object
32 33 34 35 |
# File 'lib/beanstalker/extend.rb', line 32 def self.included(receiver) @@methods_async_options = {} receiver.extend(ClassMethods) end |
Instance Method Details
#async_send(selector, *args) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/beanstalker/extend.rb', line 73 def async_send(selector, *args) if self.is_a?(Class) = self.send(:instance_variable_get, :@class_methods_async_options) || {} else = self.class.send(:instance_variable_get, :@methods_async_options) || {} end async_send_opts(selector, [selector.to_sym] || {}, *args) end |
#async_send_opts(selector, opts, *args) ⇒ Object
82 83 84 85 |
# File 'lib/beanstalker/extend.rb', line 82 def async_send_opts(selector, opts, *args) = (opts, self, *args) Beanstalker::Queue.put_call!(self, selector, , args) end |
#interpolate_async_options(options, object, *args) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/beanstalker/extend.rb', line 61 def (, object, *args) result = {} .each do |k,v| result[k] = if v.is_a?(Proc) v.call(object, *args) else v end end result end |
#rrepr ⇒ Object
190 191 192 193 |
# File 'lib/beanstalker/queue.rb', line 190 def rrepr() method = (respond_to? :get_cache) ? 'get_cache' : 'find' "#{self.class.rrepr}.#{method}(#{id.rrepr})" end |