Module: Transit::Marshaler::VerboseHandlers Private

Included in:
VerboseJson
Defined in:
lib/transit/marshaler/base.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Included in VerboseJson subclasses. Defined here to make it available in CRuby and JRuby environments.

Instance Method Summary collapse

Instance Method Details

#build_handlers(custom_handlers) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/transit/marshaler/base.rb', line 28

def build_handlers(custom_handlers)
  if VERBOSE_HANDLER_CACHE.has_key?(custom_handlers)
    VERBOSE_HANDLER_CACHE[custom_handlers]
  else
    handlers = super(custom_handlers).reduce({}) do |h, (k,v)|
      if v.respond_to?(:verbose_handler) && vh = v.verbose_handler
        h.store(k, vh)
      else
        h.store(k, v)
      end
      h
    end
    VERBOSE_HANDLER_CACHE[custom_handlers] = handlers
    handlers
  end
end