empty_object
EmptyObject is a super cleaned out class inheritance for metaprogramming and DSL making
Example
require 'empty_object'
class Test < EmptyObject
def hello_world obj= nil
if obj.nil?
obj= "world"
end
::Kernel.puts("Hello #{obj}!")
end
def method_missing(method, *args)
#DSL here
self.hello_world method
end
end
test= Test.new
test.test
#> Hello test!
test.sup?
#> Hello sup?!
test.woooooooooooooooooooorld!
#> Hello woooooooooooooooooooorld!!
Only defined methods are
- alias
- send
- object_id
Have fun metaprogramming! :)