summaryrefslogtreecommitdiff
path: root/ext/json/lib/json/add/set.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-02-23 03:43:58 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-02-23 03:43:58 +0000
commit6604e1b7cd75bef7ed72db699d8f88a7fb56c330 (patch)
treeb92ad3bacaa1f7f54152af362decaadc30466617 /ext/json/lib/json/add/set.rb
parentf22ffd83e92a214a697e93fe715d29cbfa52084d (diff)
Merge json-2.2.0 from flori/json.
https://github.com/flori/json/releases/tag/v2.2.0 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/json/lib/json/add/set.rb')
-rw-r--r--ext/json/lib/json/add/set.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/ext/json/lib/json/add/set.rb b/ext/json/lib/json/add/set.rb
new file mode 100644
index 0000000000..71e2a0ac8b
--- /dev/null
+++ b/ext/json/lib/json/add/set.rb
@@ -0,0 +1,29 @@
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+defined?(::Set) or require 'set'
+
+class Set
+ # Import a JSON Marshalled object.
+ #
+ # method used for JSON marshalling support.
+ def self.json_create(object)
+ new object['a']
+ end
+
+ # Marshal the object to JSON.
+ #
+ # method used for JSON marshalling support.
+ def as_json(*)
+ {
+ JSON.create_id => self.class.name,
+ 'a' => to_a,
+ }
+ end
+
+ # return the JSON value
+ def to_json(*args)
+ as_json.to_json(*args)
+ end
+end
+