#!/usr/local/bin/ruby module KMHash def method_missing(method, *params) method_string = method.to_s if (method_string[-1] == "="[0]) self[method_string[0..-2]] = params.first else self[method_string] end end end # this works dan = Hash.new.extend KMHash dan.kogai = 'blogger' p dan.kogai # this throws an exception matz = Hash.new matz.yukihiro = 'rubyist' p matz.yukihiro