[前][次][番号順一覧][スレッド一覧]

ruby-changes:64417

From: Kenta <ko1@a...>
Date: Mon, 21 Dec 2020 22:41:43 +0900 (JST)
Subject: [ruby-changes:64417] 0b6a80c0be (master): [json] Avoid method redefinition

https://git.ruby-lang.org/ruby.git/commit/?id=0b6a80c0be

From 0b6a80c0beec5afb3a98535c5bc851bb77b3a5e2 Mon Sep 17 00:00:00 2001
From: Kenta Murata <mrkn@m...>
Date: Mon, 21 Dec 2020 22:40:38 +0900
Subject: [json] Avoid method redefinition


diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb
index 747effe..d58c7ea 100644
--- a/ext/json/lib/json/common.rb
+++ b/ext/json/lib/json/common.rb
@@ -103,11 +103,6 @@ module JSON https://github.com/ruby/ruby/blob/trunk/ext/json/lib/json/common.rb#L103
     # 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 https://github.com/ruby/ruby/blob/trunk/ext/json/lib/json/common.rb#L111
   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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]