summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2012-04-27 20:03:16 +0200
committerFlorian Frank <flori@ping.de>2012-04-28 03:18:03 +0200
commit2e402dc8771a2de8c3cc83fcd1fb4240afd77576 (patch)
tree77cd7ca75ee36ed0ef207915974bc5d0ac4ac044 /lib
parent93b31b8b588461901ed5ae0dc4e961ea3adbc55e (diff)
downloadjson-2e402dc8771a2de8c3cc83fcd1fb4240afd77576.tar.gz
Add JSON::GenericObject
Diffstat (limited to 'lib')
-rw-r--r--lib/json/common.rb2
-rw-r--r--lib/json/generic_object.rb (renamed from lib/json/light_object.rb)14
2 files changed, 5 insertions, 11 deletions
diff --git a/lib/json/common.rb b/lib/json/common.rb
index e8e76b6..a30e4ce 100644
--- a/lib/json/common.rb
+++ b/lib/json/common.rb
@@ -1,5 +1,5 @@
require 'json/version'
-require 'json/light_object'
+require 'json/generic_object'
module JSON
class << self
diff --git a/lib/json/light_object.rb b/lib/json/generic_object.rb
index 07eeecf..7f3dbbd 100644
--- a/lib/json/light_object.rb
+++ b/lib/json/generic_object.rb
@@ -1,7 +1,7 @@
require 'ostruct'
module JSON
- class LightObject < OpenStruct
+ class GenericObject < OpenStruct
class << self
alias [] new
@@ -17,11 +17,11 @@ module JSON
end
def [](name)
- to_hash[name.to_sym]
+ table[name.to_sym]
end
def []=(name, value)
- modifiable[name.to_sym] = value
+ __send__ "#{name}=", value
end
def |(other)
@@ -29,17 +29,11 @@ module JSON
end
def as_json(*)
- to_hash | { JSON.create_id => self.class.name }
+ { JSON.create_id => self.class.name }.merge to_hash
end
def to_json(*a)
as_json.to_json(*a)
end
-
- def method_missing(*a, &b)
- to_hash.__send__(*a, &b)
- rescue NoMethodError
- super
- end
end
end