summaryrefslogtreecommitdiff
path: root/lib/csv
diff options
context:
space:
mode:
authorSutou Kouhei <kou@clear-code.com>2021-09-15 15:58:57 +0900
committerSutou Kouhei <kou@cozmixng.org>2021-10-24 05:57:33 +0900
commit39ecdabe67d1bc7c864ada6f282590dbc9d3a14e (patch)
tree4b01e5388ee0667feaccc3547e1e10acb5b808d9 /lib/csv
parent8aaa1c279f7c05a22dd108888d425565fc43e26f (diff)
[ruby/csv] Resolve CSV::Converters and HeaderConverters lazy
It's for Ractor. If you want to use the built-in converters, you should call Ractor.make_shareable(CSV::Converters) and/or Ractor.make_shareable(CSV::HeaderConverters). https://github.com/ruby/csv/commit/b0b1325d6b
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5010
Diffstat (limited to 'lib/csv')
-rw-r--r--lib/csv/fields_converter.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/csv/fields_converter.rb b/lib/csv/fields_converter.rb
index 178ffb37bc..b206118d99 100644
--- a/lib/csv/fields_converter.rb
+++ b/lib/csv/fields_converter.rb
@@ -16,7 +16,7 @@ class CSV
@empty_value = options[:empty_value]
@empty_value_is_empty_string = (@empty_value == "")
@accept_nil = options[:accept_nil]
- @builtin_converters = options[:builtin_converters]
+ @builtin_converters_name = options[:builtin_converters_name]
@need_static_convert = need_static_convert?
end
@@ -24,7 +24,7 @@ class CSV
if name.nil? # custom converter
@converters << converter
else # named converter
- combo = @builtin_converters[name]
+ combo = builtin_converters[name]
case combo
when Array # combo converter
combo.each do |sub_name|
@@ -80,5 +80,9 @@ class CSV
@need_static_convert or
(not @converters.empty?)
end
+
+ def builtin_converters
+ @builtin_converters ||= ::CSV.const_get(@builtin_converters_name)
+ end
end
end