summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2016-06-09 17:42:22 +0200
committerFlorian Frank <flori@ping.de>2016-06-21 10:56:58 +0200
commit29c918ad9e16f3b67780a141353df05c029eb1eb (patch)
tree7030ed6c7ff244509faa1deb063a28a873c56f3b
parent1e5684ff2cbde8be819eac1e50e0edbfd120d77b (diff)
downloadjson-29c918ad9e16f3b67780a141353df05c029eb1eb.tar.gz
Support 1.9 ruby's OpenStruct
-rw-r--r--lib/json/generic_object.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/json/generic_object.rb b/lib/json/generic_object.rb
index 6c8f039..108309d 100644
--- a/lib/json/generic_object.rb
+++ b/lib/json/generic_object.rb
@@ -48,6 +48,14 @@ module JSON
table
end
+ def [](name)
+ __send__(name)
+ end unless method_defined?(:[])
+
+ def []=(name, value)
+ __send__("#{name}=", value)
+ end unless method_defined?(:[]=)
+
def |(other)
self.class[other.to_hash.merge(to_hash)]
end