Class: Mpql::Formatters::JsonFormatter
- Inherits:
-
Object
- Object
- Mpql::Formatters::JsonFormatter
- Defined in:
- lib/mpql/formatters/json_formatter.rb
Instance Method Summary collapse
-
#initialize(data, raw: false) ⇒ JsonFormatter
constructor
A new instance of JsonFormatter.
- #render ⇒ Object
Constructor Details
#initialize(data, raw: false) ⇒ JsonFormatter
Returns a new instance of JsonFormatter.
8 9 10 11 |
# File 'lib/mpql/formatters/json_formatter.rb', line 8 def initialize(data, raw: false) @data = data @raw = raw end |
Instance Method Details
#render ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/mpql/formatters/json_formatter.rb', line 13 def render if @raw JSON.generate(@data) else JSON.pretty_generate(@data) end end |