Sha256: 90105d7e50ab3d1e0548773cfb1018d27bb2b7d36514d541f0f344483c86af04
Contents?: true
Size: 1.09 KB
Versions: 9
Compression:
Stored size: 1.09 KB
Contents
module Tdc module ExtendedAttributes # # Knows the class instances that interpret extended attribute values. # class InterpreterRegistry include Singleton def self.register(interpreter:) instance.register_interpreter(interpreter) end def initialize @interpreters = [] end def clear @interpreters = [] end def interpreters @interpreters.empty? ? [default_interpreter] : @interpreters end def register_interpreter(interpreter) raise Tdc::FatalError, <<~MSG.chomp unless interpreter.is_a?(Tdc::ExtendedAttributes::InterpreterBase) Cannot register an interpreter unless it inherits from Tdc::ExtendedAttributes::InterpreterBase MSG # Avoid registering the same class of interpreter a second time. return if @interpreters.map(&:class).include?(interpreter.class) @interpreters << interpreter end private def default_interpreter @_default_interpreter ||= Tdc::ExtendedAttributes::DefaultInterpreter.new end end end end
Version data entries
9 entries across 9 versions & 1 rubygems