#!/usr/bin/env ruby
class Dog
def name() "Rover" end
def talk() puts "Woof" end
end
class Proxy
def initialize(realobj)
@realobj = realobj
end
def method_missing(sym, *args, &block)
@realobj.send(sym, *args, &block)
end
end
dog = Dog.new
prox = Proxy.new(dog)
puts "My dogs name is #{prox.name}"
prox.talk
|
|
[ Index ][ Table of Contents ] | Generated by [ source2html ] |