test.rb in mirage-2.0.8 vs test.rb in mirage-2.0.9

- old
+ new

@@ -1,8 +1,22 @@ -hash = Hash.new do |hash, key| - hash[key] = Hash.new do |patterns_hash, pattern| - patterns_hash[pattern] = {:blah => 'foo'} +class Hash + alias_method :backup, :[] + + def [] desired_key + result = backup(desired_key) + return result if result + key, value = find{|key, value| key.is_a?(Regexp) && desired_key.is_a?(String) && key.match(desired_key) } + value end end -hash = hash['thing']['whatever'] +hash = {/hello/ => 'hello', :foo => 'bar'} -puts hash +#def hash.[] desired_key +# key, value = find{|key, value| key.match(desired_key)} +# value +#end + + +puts hash['hello'] +puts hash[:foo] + +Marshal.dump(hash) \ No newline at end of file