Class: BufferedJob::Proxy
- Inherits:
-
Object
- Object
- BufferedJob::Proxy
- Defined in:
- lib/buffered_job/proxy.rb
Instance Method Summary collapse
-
#initialize(receiver, user, key, opt = {}) ⇒ Proxy
constructor
A new instance of Proxy.
- #method_missing(method, target) ⇒ Object
Constructor Details
#initialize(receiver, user, key, opt = {}) ⇒ Proxy
Returns a new instance of Proxy.
3 4 5 6 7 8 |
# File 'lib/buffered_job/proxy.rb', line 3 def initialize(receiver,user,key,opt={}) @receiver = receiver @user = user @opt = opt @key = key end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, target) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/buffered_job/proxy.rb', line 10 def method_missing(method,target) @key ||= ( @receiver.class == Class ? @receiver.to_s : @receiver.class.to_s) + '#' + method.to_s merge_method = @opt[:action] || "merge_#{method}".to_sym user_id = @user.respond_to?(:id) ? @user.id : 0 BufferedJob::Model.create(:user_id => user_id, :category => @key, :receiver => @receiver, :method => method.to_sym, :merge_method => merge_method, :target => target) end |