Class: Droiuby::Wrappers::Listeners::AutoWrapMultiple

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, impl_blocks = {}) ⇒ AutoWrapMultiple

Returns a new instance of AutoWrapMultiple.



36
37
38
39
# File 'lib/droiuby/wrappers/listeners/auto_wrap.rb', line 36

def initialize(execution_bundle, impl_blocks = {})
  @execution_bundle = execution_bundle
  @auto_wrap_blocks = impl_blocks
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/droiuby/wrappers/listeners/auto_wrap.rb', line 45

def method_missing(meth, *args, &block)
  if meth.to_s =~ /^on(.+)$/
    wrapped_args = args.collect { |a|
      wrap_native_view(a)
    }
    @auto_wrap_block[meth.to_s].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

Instance Method Details

#impl(method, &block) ⇒ Object



41
42
43
# File 'lib/droiuby/wrappers/listeners/auto_wrap.rb', line 41

def impl(method, &block)
  @auto_wrap_block["on#{meth.to_s.camelize}"] = block
end