datasource-arrayschema.js revision 815899c9e9780cd8b2d1c6368753c56afc5be443
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * Extends DataSource with schema-parsing on array data.
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * @module datasource
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * @submodule datasource-arrayschema
8392a541bf432ed8d6e1985b6306b83dc898768dJenny Han Donnelly * Adds schema-parsing to the DataSource Utility.
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * @class DataSourceArraySchema
32b6fd78d1787b0afecb1970111f14a46a569aa7Jenny Han Donnelly * @extends Plugin.Base
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly DataSourceArraySchema.superclass.constructor.apply(this, arguments);
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * The namespace for the plugin. This will be the property on the host which
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * references the plugin instance.
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * @property NS
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * @type String
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * @value "schema"
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * @property NAME
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * @type String
1e0aa6df8881a856ec262f103bfee1c0a05d19b9Jenny Han Donnelly * @value "dataSourceArraySchema"
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly /////////////////////////////////////////////////////////////////////////////
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly // DataSourceArraySchema Attributes
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly /////////////////////////////////////////////////////////////////////////////
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han DonnellyY.extend(DataSourceArraySchema, Y.Plugin.Base, {
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * Internal init() handler.
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * @method initializer
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * @param config {Object} Config object.
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly this.doBefore("_defDataFn", this._beforeDefDataFn);
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * Parses raw data into a normalized response.
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * @method _beforeDefDataFn
815899c9e9780cd8b2d1c6368753c56afc5be443Ryan Grove * @param tId {Number} Unique transaction ID.
815899c9e9780cd8b2d1c6368753c56afc5be443Ryan Grove * @param request {Object} The request.
815899c9e9780cd8b2d1c6368753c56afc5be443Ryan Grove * @param callback {Object} The callback object with the following properties:
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * <dt>success (Function)</dt> <dd>Success handler.</dd>
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly * <dt>failure (Function)</dt> <dd>Failure handler.</dd>
815899c9e9780cd8b2d1c6368753c56afc5be443Ryan Grove * @param data {Object} Raw data.
350839d3f8c71a522972265f77a8b5a3fbf6c82fJenny Han Donnelly var data = (Y.DataSource.IO && (this.get("host") instanceof Y.DataSource.IO) && Y.Lang.isString(e.data.responseText)) ? e.data.responseText : e.data,
c1641e80c2d0d5db16cd79f19b76ad8fc1fb4921Jenny Donnelly response = Y.DataSchema.Array.apply.call(this, this.get("schema"), data);
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly this.get("host").fire("response", Y.mix({response:response}, e));
fe0eaf3c7c1942b0a300cd5f3952ada16fb18781Jenny Han Donnelly return new Y.Do.Halt("DataSourceArraySchema plugin halted _defDataFn");