Mojo.Model

Namespace Detail

Method Summary


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

Returns

{Object} a new decorator object for the given 'original' object.


{string} Mojo.Model.decrypt(key, data)

The string returned is a Base 64 decoded version of the Blowfish decrypted version of the source string. See this article for a description of Blowfish encryption. The strength of the encryption depends on the length of the key provided. For example, a 16-byte-long string is equivalent to a 128-bit key.

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

Returns

{string} Base 64 decoded version of the Blowfish-decrypted version of the source string.


{string} Mojo.Model.encrypt(key, data)

The string returned is a Base 64 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

Returns

{string} Base 64 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