Class: MayI::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/mayi/proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(target, &block) ⇒ Proxy

Returns a new instance of Proxy.



5
6
7
8
# File 'lib/mayi/proxy.rb', line 5

def initialize(target,&block)
  @target = target
  @block = block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (protected)



12
13
14
15
16
17
# File 'lib/mayi/proxy.rb', line 12

def method_missing(name, *args, &block)
  @block.call(:before)
  @target.send(name, *args, &block)
ensure
  @block.call(:after)
end