/ Published in: Ruby
Creating a object that doesn't have any methods in Ruby (regular objects inherit methods from Object class), useful for Proxies that use method missing (http://onestepback.org/index.cgi/Tech/Ruby/BlankSlate.rdoc).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
lass BlankSlate instance_methods.each { |m| undef_method m unless m =~ /^__/ } end # All methods will be passed to method_missing class Proxy < BlankSlate def initialize(obj) @obj = obj end def method_missing(sym, *args, &block) puts "Sending #{sym}(#{args.join(',')}) to obj" @obj.__send__(sym, *args, &block) end end