76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Extends DataSource with schema-parsing on JSON data.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @module datasource
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @submodule datasource-jsonschema
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Adds schema-parsing to the DataSource Utility.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @class DataSourceJSONSchema
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @extends Plugin.Base
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glassvar DataSourceJSONSchema = function() {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass DataSourceJSONSchema.superclass.constructor.apply(this, arguments);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * The namespace for the plugin. This will be the property on the host which
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * references the plugin instance.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @property NS
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @type String
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @value "schema"
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Class name.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @property NAME
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @type String
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @value "dataSourceJSONSchema"
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass /////////////////////////////////////////////////////////////////////////////
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass // DataSourceJSONSchema Attributes
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass /////////////////////////////////////////////////////////////////////////////
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Internal init() handler.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @method initializer
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param config {Object} Config object.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass this.doBefore("_defDataFn", this._beforeDefDataFn);
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * Parses raw data into a normalized response. To accommodate XHR responses,
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * will first look for data in data.responseText. Otherwise will just work
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * with data.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @method _beforeDefDataFn
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param tId {Number} Unique transaction ID.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param request {Object} The request.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param callback {Object} The callback object with the following properties:
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * <dt>success (Function)</dt> <dd>Success handler.</dd>
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * <dt>failure (Function)</dt> <dd>Failure handler.</dd>
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @param data {Object} Raw data.
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass * @protected
2fe13ddab136a6eb6239d89e5e064e09d9e1bb92Luke Smith var data = e.data && (e.data.responseText || e.data),
2fe13ddab136a6eb6239d89e5e064e09d9e1bb92Luke Smith payload.response = Y.DataSchema.JSON.apply.call(this, schema, data) || {
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass return new Y.Do.Halt("DataSourceJSONSchema plugin halted _defDataFn");
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav GlassY.namespace('Plugin').DataSourceJSONSchema = DataSourceJSONSchema;
76ca635d61eb3f9fb7c9d788a44fa8b1690aa138Dav Glass}, '@VERSION@' ,{requires:['datasource-local', 'plugin', 'dataschema-json']});