Method: YARD::Templates::Engine.with_serializer

Defined in:
lib/yard/templates/engine.rb

.with_serializer(object, serializer) { ... } ⇒ Object

Serializes the results of a block with a serializer object.

Parameters:

Yields:

  • a block whose result will be serialize

Yield Returns:

  • (String)

    the contents to serialize

See Also:



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/yard/templates/engine.rb', line 115

def with_serializer(object, serializer)
  output = nil
  filename = serializer.serialized_path(object)
  if serializer.respond_to?(:basepath)
    filename = File.join(serializer.basepath, filename)
  end
  log.capture("Generating #{filename}", nil) do
    serializer.before_serialize if serializer
    output = yield
    if serializer
      serializer.serialize(object, output)
      serializer.after_serialize(output)
    end
  end
  output
end