Class: Vedeu::Renderers::JSON Private

Inherits:
File
  • Object
show all
Includes:
Options
Defined in:
lib/vedeu/renderers/json.rb

Overview

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

Renders a Buffers::Terminal as JSON.

Instance Attribute Summary

Attributes included from Options

#options

Instance Method Summary collapse

Methods included from Options

#compression, #compression?, #default_template, #defaults, #end_row_tag, #end_tag, #filename, #initialize, #output, #output?, #render, #start_row_tag, #start_tag, #template, #timestamp, #timestamp?, #write, #write_file, #write_file?

Methods included from Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Methods inherited from File

#write, #write_file?

Instance Method Details

#as_hashArray (private)

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.

Returns:

  • (Array)


25
26
27
# File 'lib/vedeu/renderers/json.rb', line 25

def as_hash
  output.content.map(&:to_h)
end

#clearHash

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.

Render a cleared output.

Returns:

  • (Hash)


18
19
20
# File 'lib/vedeu/renderers/json.rb', line 18

def clear
  render({})
end

#contentString (private)

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.

Returns:

  • (String)


30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vedeu/renderers/json.rb', line 30

def content
  if hash?(output)
    ::JSON.pretty_generate(output)

  else
    Vedeu.log(type:    :render,
              message: "#{self.class.name}#content: #{output.class.name}")

    ::JSON.pretty_generate(as_hash)
  end
end