Created
July 17, 2012 04:48
-
-
Save kborchers/3127213 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Need to add license, description, etc. */ | |
// This will be broken into its own file to be reused | |
(function( window, undefined ) { | |
var aerogear = window.aerogear = { | |
}; | |
})( this ); | |
// AeroGear Pipeline | |
(function( aerogear, undefined ) { | |
aerogear.pipeline = function( pipe ) { | |
var config = pipe || {}, | |
pipes = {}; | |
if ( typeof config === "string" ) { | |
pipes[ config ] = aerogear.pipeline.adapters.rest( config ); | |
} | |
return pipes; | |
}; | |
aerogear.pipeline.adapters = {}; | |
})( aerogear ); | |
// Rest Adapter (default) | |
(function( aerogear, $, undefined ) { | |
aerogear.pipeline.adapters.rest = function( pipeName, ajaxSettings ) { | |
ajaxSettings = $.extend({ | |
// use the pipeName as the default rest endpoint | |
url: pipeName | |
}, ajaxSettings ); | |
return { | |
read: function( options ) { | |
options = options || {}; | |
ajaxSettings = $.extend({ | |
type: "GET" | |
}, options.ajax || {}, ajaxSettings ); | |
return $.ajax( ajaxSettings ); | |
}, | |
save: function( data, options ) { | |
options = options || {}; | |
ajaxSettings = $.extend({ | |
type: "POST", | |
data: data | |
}, options.ajax || {}, ajaxSettings ); | |
return $.ajax( ajaxSettings ); | |
} | |
}; | |
}; | |
})( aerogear, jQuery ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment