1
0
mirror of https://github.com/meineerde/rackstash.git synced 2025-10-17 14:01:01 +00:00

Dup object_type for class registry only if required

This commit is contained in:
Holger Just 2020-07-10 17:46:25 +02:00
parent ef57352e1f
commit eaa13c8111

View File

@ -1,14 +1,18 @@
# frozen_string_literal: true # frozen_string_literal: true
# #
# Copyright 2017 Holger Just # Copyright 2017 - 2020 Holger Just
# #
# This software may be modified and distributed under the terms # This software may be modified and distributed under the terms
# of the MIT license. See the LICENSE.txt file for details. # of the MIT license. See the LICENSE.txt file for details.
require 'rackstash/utils'
module Rackstash module Rackstash
class ClassRegistry class ClassRegistry
include ::Enumerable include ::Enumerable
include Rackstash::Utils
# @return [String] the human-readable singular name of the registered # @return [String] the human-readable singular name of the registered
# objects. It is used to build more useful error messages. # objects. It is used to build more useful error messages.
attr_reader :object_type attr_reader :object_type
@ -16,7 +20,7 @@ module Rackstash
# @param object_type [#to_s] the human-readable singular name of the # @param object_type [#to_s] the human-readable singular name of the
# registered objects. It is used to build more useful error messages. # registered objects. It is used to build more useful error messages.
def initialize(object_type = 'class') def initialize(object_type = 'class')
@object_type = object_type.to_s.dup.freeze @object_type = utf8(object_type)
@registry = {} @registry = {}
end end