diff options
| author | Igor Minar | 2011-02-15 01:12:45 -0500 | 
|---|---|---|
| committer | Igor Minar | 2011-02-15 11:01:53 -0500 | 
| commit | 1777110958f76ee4be5760e36c96702223385918 (patch) | |
| tree | 5aa03b246507e66877e5eac69e58e004e244d7a5 /src/service/cookieStore.js | |
| parent | d2089a16335276eecb8d81eb17332c2dff2cf1a2 (diff) | |
| download | angular.js-1777110958f76ee4be5760e36c96702223385918.tar.bz2 | |
split up services into individual files
- split up services into files under src/service
- split up specs into files under test/service
- rewrite all specs so that they don't depend on one global forEach
- get rid of obsolete code and tests in ng:switch
- rename mock $log spec from "$log" to "$log mock"
Diffstat (limited to 'src/service/cookieStore.js')
| -rw-r--r-- | src/service/cookieStore.js | 64 | 
1 files changed, 64 insertions, 0 deletions
diff --git a/src/service/cookieStore.js b/src/service/cookieStore.js new file mode 100644 index 00000000..089e4578 --- /dev/null +++ b/src/service/cookieStore.js @@ -0,0 +1,64 @@ +/** + * @workInProgress + * @ngdoc service + * @name angular.service.$cookieStore + * @requires $cookies + * + * @description + * Provides a key-value (string-object) storage, that is backed by session cookies. + * Objects put or retrieved from this storage are automatically serialized or + * deserialized by angular's toJson/fromJson. + * @example + */ +angularServiceInject('$cookieStore', function($store) { + +  return { +    /** +     * @workInProgress +     * @ngdoc method +     * @name angular.service.$cookieStore#get +     * @methodOf angular.service.$cookieStore +     * +     * @description +     * Returns the value of given cookie key +     * +     * @param {string} key Id to use for lookup. +     * @returns {Object} Deserialized cookie value. +     */ +    get: function(key) { +      return fromJson($store[key]); +    }, + +    /** +     * @workInProgress +     * @ngdoc method +     * @name angular.service.$cookieStore#put +     * @methodOf angular.service.$cookieStore +     * +     * @description +     * Sets a value for given cookie key +     * +     * @param {string} key Id for the `value`. +     * @param {Object} value Value to be stored. +     */ +    put: function(key, value) { +      $store[key] = toJson(value); +    }, + +    /** +     * @workInProgress +     * @ngdoc method +     * @name angular.service.$cookieStore#remove +     * @methodOf angular.service.$cookieStore +     * +     * @description +     * Remove given cookie +     * +     * @param {string} key Id of the key-value pair to delete. +     */ +    remove: function(key) { +      delete $store[key]; +    } +  }; + +}, ['$cookies']);  | 
