Class: Magent::Async::Proxy
- Inherits:
-
Object
- Object
- Magent::Async::Proxy
- Defined in:
- lib/magent/async.rb
Instance Method Summary collapse
- #commit!(priority = 3) ⇒ Object
-
#initialize(queue, target, test = false) ⇒ Proxy
constructor
A new instance of Proxy.
- #method_missing(m, *args, &blk) ⇒ Object
Constructor Details
#initialize(queue, target, test = false) ⇒ Proxy
Returns a new instance of Proxy.
29 30 31 32 33 34 35 36 |
# File 'lib/magent/async.rb', line 29 def initialize(queue, target, test = false) @queue = queue @method_chain = [] @target = target @test = test @channel = Magent::AsyncChannel.new(@queue) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &blk) ⇒ Object
51 52 53 54 55 |
# File 'lib/magent/async.rb', line 51 def method_missing(m, *args, &blk) raise ArgumentError, "ruby blocks are not supported yet" if !blk.nil? @method_chain << [m, args] self end |
Instance Method Details
#commit!(priority = 3) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/magent/async.rb', line 38 def commit!(priority = 3) @channel.push(@target, @method_chain, priority) if @test target = @target @method_chain.each do |c| target = target.send(c[0], *c[1]) end target end end |