Mojo

Namespace Detail

This section contains some methods that can be used to debug your applications and other utility functions (assert, require, loadScriptWithCallback...)

Method Summary


Method Detail

{String} Mojo.assert(expression, message, messageProperties)

Writes an error to the log if expression doesn't evaluate to boolean true.

The Mojo.require or Mojo.assert methods will do the same, except that require will throw an exception when their requirements aren't met. These are intended to be used in cases where framework code or application cannot reasonably continue if the requirements aren't met.

Example:

Mojo.assert(dogs > 3,
  "expected dogs to be greater than #{count}, but it was #{amount}",
  {count: 3, amount: dogs}) 

Parameters

Returns

{String} the message that was written to the log.


{string} Mojo.assertArray(expectedArray, message, messageProperties)

Writes an error to the log if expectedArray fails the Prototype isArray method.

Parameters

Returns

The message that was written to the log.


{string} Mojo.assertClass(object, constructorFunction, message, messageProperties)

Writes an error to the log if targetObject wasn't constructed by the passed-in constructor function.

Parameters

Returns

The message that was written to the log.


{string} Mojo.assertDefined(value, message, messageProperties)

Writes an error to the log if value evaluates to undefined.

Parameters

Returns

The message that was written to the log.


{string} Mojo.assertElement(expectedElement, message, messageProperties)

Writes an error to the log if expectedElement fails the Prototype isElement method.

Parameters

Returns

The message that was written to the log.


{string} Mojo.assertEqual(expected, actual, message, messageProperties)

Writes an error to the log if expected === actual is not true.

Parameters

Returns

The message that was written to the log.


{string} Mojo.assertFalse(expression, message, messageProperties)

Writes an error to the log if expression evaluates to boolean true.

Parameters

Returns

The message that was written to the log.


{string} Mojo.assertFunction(expectedFunction, message, messageProperties)

Writes an error to the log if expectedFunction fails the Prototype isFunction method.

Parameters

Returns

The message that was written to the log.


{string} Mojo.assertMatch(regex, testValue, message, messageProperties)

Writes an error to the log if the regex doesn't match the testValue.

Parameters

Returns

The message that was written to the log.


{string} Mojo.assertNumber(expectedNumber, message, messageProperties)

Writes an error to the log if expectedNumber fails the Prototype isNumber method.

Parameters

Returns

The message that was written to the log.


Mojo.assertProperty(properties)

Writes an error to the log if targetObject doesn't have values for the property name or names passed in.

Parameters


{string} Mojo.assertString(expectedString, message, messageProperties)

Writes an error to the log if expectedString fails the Prototype isString method.

Parameters

Returns

The message that was written to the log.


Mojo.doNothing()

A simple empty function useful as a stub.


Mojo.loadScriptWithCallback(path, callback, optionalDocument)

Asynchronously load a JavaScript file by adding a script tag to the header of the document.

Parameters


Mojo.parseJSON(jsonText)

Parses a text string of encoded in JSON, returning a JavaScript object (result) when successful.

Parameters


{String} Mojo.require(expression, message, messageProperties)

Writes an error to the log if expression doesn't evaluate to boolean true.

The Mojo.require and Mojo.assert methods will do the same thing, except that Mojo.require will throw an exception when its requirements aren't met. The Mojo.requireXxxx methods are intended to be used in cases where framework code or application cannot reasonably continue if the requirements aren't met.

Example:

Mojo.require(dogs > 3,
  "expected dogs to be greater than #{count}, but it was #{amount}",
  {count: 3, amount: dogs}) 

Parameters

Returns

{String} the message that was written to the log.


{string} Mojo.requireArray(expectedArray, message, messageProperties)

Writes an error to the log if expectedArray fails the Prototype isArray method and throws an exception.

Parameters

Returns

The message that was written to the log.


{string} Mojo.requireClass(object, constructorFunction, message, messageProperties)

Writes an error to the log if targetObject wasn't constructed by the passed in constructor function and throws an exception.

Parameters

Returns

The message that was written to the log.


{string} Mojo.requireDefined(value, message, messageProperties)

Writes an error to the log if value evaluates to undefined and throws an exception.

Parameters

Returns

The message that was written to the log.


{string} Mojo.requireElement(expectedElement, message, messageProperties)

Writes an error to the log if expectedElement fails the Prototype isElement method and throws an exception.

Parameters

Returns

The message that was written to the log.


{string} Mojo.requireEqual(expected, actual, message, messageProperties)

Writes an error to the log if expected === actual is not true and throws an exception.

Parameters

Returns

The message that was written to the log.


{string} Mojo.requireFalse(expression, message, messageProperties)

Writes an error to the log if expression evaluates to boolean true and throws an exception.

Parameters

Returns

The message that was written to the log


{string} Mojo.requireFunction(expectedFunction, message, messageProperties)

Writes an error to the log if expectedFunction fails the Prototype isFunction method and throws an exception.

Parameters

Returns

The message that was written to the log.


{string} Mojo.requireMatch(regex, testValue, message, messageProperties)

Writes an error to the log if the regex doesn't match the testValue and throws an exception.

Parameters

Returns

The message that was written to the log.


{string} Mojo.requireNumber(expectedNumber, message, messageProperties)

Writes an error to the log if expectedNumber fails the Prototype isNumber method and throws an exception.

Parameters

Returns

The message that was written to the log.


Mojo.requireProperty(properties)

Writes an error to the log if targetObject doesn't have values for the property name or names passed in and throws an exception.

Parameters


{string} Mojo.requireString(expectedString, message, messageProperties)

Writes an error to the log if expectedString fails the Prototype isString method and throws an exception.

Parameters

Returns

The message that was written to the log.