lib/ruote/util/hashdot.rb in ruote-2.2.0 vs lib/ruote/util/hashdot.rb in ruote-2.3.0
- old
+ new
@@ -1,7 +1,7 @@
#--
-# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
+# Copyright (c) 2005-2012, John Mettraux, jmettraux@gmail.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -30,22 +30,18 @@
def method_missing(m, *args)
m = m.to_s
if m[-1, 1] == '='
-
- val = args.first
- self[m[0..-2]] = val
-
- return val
-
+ if args.first.nil?
+ self.delete(m[0..-2]); nil
+ else
+ self[m[0..-2]] = args.first
+ end
else
-
- return self[m] #if self.has_key?(m)
+ self[m]
end
-
- #super
end
def dump
s = "~~ h ~~\n"
@@ -53,12 +49,18 @@
s << " * '#{k}' => "
s << v.inspect
s << "\n"
end
s << "~~ . ~~"
-
- s
end
+
+ #--
+ # Useful when debugging some 'stack too deep' issue
+ #
+ #def self.included(target)
+ # raise target.to_s unless target.to_s.match(/\bHash\b/)
+ #end
+ #++
end
module WithH
def self.included(target)