Class: Droiuby::Wrappers::Listeners::AutoWrap

Inherits:
AutoWrapBase show all
Defined in:
lib/droiuby/wrappers/listeners/auto_wrap.rb

Instance Method Summary collapse

Methods inherited from AutoWrapBase

#to_native

Constructor Details

#initialize(execution_bundle, auto_wrap_block) ⇒ AutoWrap

Returns a new instance of AutoWrap.



13
14
15
16
# File 'lib/droiuby/wrappers/listeners/auto_wrap.rb', line 13

def initialize(execution_bundle, auto_wrap_block)
  @execution_bundle = execution_bundle
  @auto_wrap_block = auto_wrap_block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/droiuby/wrappers/listeners/auto_wrap.rb', line 18

def method_missing(meth, *args, &block)
  if meth.to_s =~ /^on(.+)$/
    wrapped_args = args.collect { |a|
      wrap_native_view(a)
    }
    @auto_wrap_block.call(*wrapped_args)
  else
    super # You *must* call super if you don't handle the
          # method, otherwise you'll mess up Ruby's method
          # lookup.
  end
end