Module: PortableExpressions::Serializable

Included in:
Environment, Expression, Scalar, Variable
Defined in:
lib/portable_expressions/modules/serializable.rb

Overview

Adds JSON serialization capabilities to each object.

Instance Method Summary collapse

Instance Method Details

#as_jsonObject



6
7
8
9
10
# File 'lib/portable_expressions/modules/serializable.rb', line 6

def as_json
  {
    object: self.class.name
  }
end

#to_json(pretty: false) ⇒ Object



12
13
14
# File 'lib/portable_expressions/modules/serializable.rb', line 12

def to_json(pretty: false)
  pretty ? JSON.pretty_generate(as_json) : JSON.generate(as_json)
end