summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenta Murata <mrkn@mrkn.jp>2020-12-21 22:40:38 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-12-22 13:58:14 +0900
commitf35ab5ee4cf6e3f1855885f86e8ed72d16752401 (patch)
tree69f45cc2da5885e9dc05dc803ece3aef6cc4ec8b
parentf1d5fb030ce758b96e13817290964d92e3516d82 (diff)
downloadjson-f35ab5ee4cf6e3f1855885f86e8ed72d16752401.tar.gz
[json] Avoid method redefinition
-rw-r--r--lib/json/common.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/json/common.rb b/lib/json/common.rb
index 747effe..d58c7ea 100644
--- a/lib/json/common.rb
+++ b/lib/json/common.rb
@@ -103,11 +103,6 @@ module JSON
# either JSON::Ext::Generator::State or JSON::Pure::Generator::State:
# JSON.state # => JSON::Ext::Generator::State
attr_accessor :state
-
- # Sets or returns create identifier, which is used to decide if the _json_create_
- # hook of a class should be called; initial value is +json_class+:
- # JSON.create_id # => 'json_class'
- attr_accessor :create_id
end
DEFAULT_CREATE_ID = 'json_class'.freeze
@@ -116,14 +111,19 @@ module JSON
CREATE_ID_TLS_KEY = "JSON.create_id".freeze
private_constant :CREATE_ID_TLS_KEY
- def self.create_id
- Thread.current[CREATE_ID_TLS_KEY] || DEFAULT_CREATE_ID
- end
-
+ # Sets create identifier, which is used to decide if the _json_create_
+ # hook of a class should be called; initial value is +json_class+:
+ # JSON.create_id # => 'json_class'
def self.create_id=(new_value)
Thread.current[CREATE_ID_TLS_KEY] = new_value.dup.freeze
end
+ # Returns the current create identifier.
+ # See also JSON.create_id=.
+ def self.create_id
+ Thread.current[CREATE_ID_TLS_KEY] || DEFAULT_CREATE_ID
+ end
+
NaN = 0.0/0
Infinity = 1.0/0