Mojo.Model

Namespace Detail
Method Summary
Method Name and Description
Mojo.Model.decorate(proto, clone)
Mojo.Model.decrypt(key, data)
Mojo.Model.encrypt(key, data)
Mojo.Model.format(model, formatters, clone)
Method Detail
{Object} Mojo.Model.decorate(proto, clone)

The idea of a decorator is that the prototype references the original object, so properties can be transparently added to (or modified in) the decorator without affecting the original.
This is really handy for widgets that need to add properties to their model in preparation for rendering.

Parameters:
{Object} proto
is the object to decorate. The new decorator object's prototype field will refer to this object.
{Object} clone
if specified, will have its properties copied into the new decorator.
Returns:
{Object} It returns a new decorator object for the given 'original' object.
{string} Mojo.Model.decrypt(key, data)

The string returned is a base64 decoded version of the blowfish decrypted version of the source string.

Example

    var key = "sfhjasf7827387af9s7d8f";
    var in_string = "This is a test string.";

    var encrypted_string = Mojo.Model.encrypt( key, in_string );

    var decrypted_string = Mojo.Model.decrypt( key, encrypted_string );
Parameters:
{string} key
is the key used to encrypt the data. A discussion of proper key generation is beyond the scope of this document.
{string} data
Base64 encoded data to be decrypted.
Returns:
{string} base64 decoded version of the blowfish decrypted version of the source string.
{string} Mojo.Model.encrypt(key, data)

The string returned is a base64 encoded version of the blowfish encrypted version of the source string.

Example

    var key = "sfhjasf7827387af9s7d8f";
    var in_string = "This is a test string.";

    var encrypted_string = Mojo.Model.encrypt( key, in_string );

    var decrypted_string = Mojo.Model.decrypt( key, encrypted_string );
Parameters:
{string} key
Encryption key to be used.
{string} data
Data to be encrypted.
Returns:
{string} base64 encoded version of the blowfish encrypted version of the source string.
Mojo.Model.format(model, formatters, clone)

Applies the relevant formatter functions in formatters, to the given model object. The formatter results are placed in a newly created decorator, so the original model is unmodified.

Formatter functions receive their property value as the first argument, and the whole model object as a second argument. They may return a string, which is used for the formatted version of the model property, or alternatively a hash of formattedPropertyName -> formattedValue, so one formatter function can create multiple formatted values from a single model property.

Parameters:
{Object} model
is the object containing the properties to be formatted. It is left unmodified.
{Object} formatters
is a hash of property names to formatter functions. The keys in the 'formatters' hash are names of properties in the model object to which the formatter functions should be applied. Formatted values have the text "formatted" appended to their names, so the unformatted value is also available.
{Object} clone
if specified, is the clone object passed to 'decorate'. Its properties are copied to the model decorator object before applying the formatter functions.

Documentation generated by JsDoc Toolkit 2.1.1 on Thu Oct 29 2009 15:28:12 GMT-0700 (PDT)