Class: Method

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

Overview

******************** kamila version 1.0.2 - Framework *********************

Copyright © 2008 Edgar Gonzalez (egonzale.wordpress.com)

This framework is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This framework is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this framework; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Este framework es software libre; puedes redistribuirlo y/o modificarlo bajo los terminos de la licencia publica general GNU tal y como fue publicada por la Fundacion del Software Libre; desde la version 2.1 o cualquier versión superior.

Este framework es distribuido con la esperanza de ser util pero SIN NINGUN TIPO DE GARANTIA; sin dejar atras su LADO MERCANTIL o PARA FAVORECER ALGUN FIN EN PARTICULAR. Lee la licencia publica general para mas detalles.

Debes recibir una copia de la Licencia Publica General GNU junto con este framework, si no es asi, escribe a Fundacion del Software Libre Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ***************************************************************************

Defined Under Namespace

Modules: Overload Classes: Signature

Class Method Summary collapse

Class Method Details

.dispatch(recv, func, args, block) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/overload.rb', line 145

def self.dispatch(recv, func, args, block)
  klass = tbl = sig = meth = nil
  recv.class.ancestors.find do |klass|
    tbl = klass.instance_eval {defined?(@overload) and @overload} or next
    tbl = tbl[func] or next
    sig, meth = tbl.find {|sig, meth| sig === args}
    meth
  end
  meth or Signature[*args].nomatch(recv, func, 3)
  begin
    recv.__send__(meth, *args, &block)
  rescue Exception
    n = -caller.size
    $@[n-2, 3] = nil
    $@[n].sub!(/\`#{func}\'\z/, "\`#{meth}\'")
    raise
  end
end