Module: Drymm::Shapes::JSONMethods

Extended by:
Mix
Included in:
Node
Defined in:
lib/drymm/shapes/json_methods.rb

Overview

JSON serialization methods mixin.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#to_json(pretty: nil) ⇒ String

Dumps the instance to a JSON string.

Parameters:

  • pretty (Hash) (defaults to: nil)

Returns:

  • (String)


14
15
16
17
18
19
20
# File 'lib/drymm/shapes/json_methods.rb', line 14

def to_json(pretty: nil)
  if pretty
    JSON.pretty_generate(to_hash, pretty)
  else
    JSON.fast_generate(to_hash)
  end
end