Class: JsonType

Defined in: lib/Types/JsonTypes.coffee
Inherits: types.MapManager

Overview

Manages Object-like values.

Variables Summary

type =
"JsonType"

Identifies this class. Use it to check whether this is a json-type or something else.

Examples:

var x = yatta.val('unknown')
if (x.type === "JsonType") {
  console.log JSON.stringify(x.toJson())
}
mutable_default =
true

Whether the default is 'mutable' (true) or 'immutable' (false)

Instance Method Summary

Constructor Details

# (void) constructor(uid, initial_value, mutable)

Parameters:

  • uid ( Object ) A unique identifier. If uid is undefined, a new uid will be created.
  • initial_value ( Object ) Create this operation with an initial value.
  • Whether ( String|Boolean ) the initial_value should be created as mutable. (Optional - see setMutableDefault)

Instance Method Details

# (void) applyDelete()

# (void) cleanup()

# (Json) toJson()

Transform this to a Json. If your browser supports Object.observe it will be transformed automatically when a change arrives. Otherwise you will loose all the sharing-abilities (the new object will be a deep clone)!

Returns:

  • Json

# (void) setReplaceManager(replace_manager)

Sets the parent of this JsonType object.

# (JsonType) getParent()

Get the parent of this JsonType.

Returns:

# (void) setMutableDefault(mutable)

Set if the default is 'mutable' or 'immutable'

Parameters:

  • mutable ( String|Boolean ) Set either 'mutable' / true or 'immutable' / false

~ (Json) val()
~ (JsonType|WordType|String|Object) val(name)
~ (JsonType) val(name, content)

Overloads:

~ (Json) val()

Get this as a Json object.

Returns:

  • Json

~ (JsonType|WordType|String|Object) val(name)

Get value of a property.

Parameters:

  • name ( String ) Name of the object property.

Returns:

  • ( JsonType|WordType|String|Object ) — Depending on the value of the property. If mutable it will return a Operation-type object, if immutable it will return String/Object.

~ (JsonType) val(name, content)

Set a new property.

Parameters:

  • name ( String ) Name of the object property.
  • content ( Object|String ) Content of the object property.

Returns:

  • ( JsonType ) — This object. (supports chaining)

# (void) _encode() Private

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: