ActiveResourceKit  v1.2 (498.0)
 All Classes Files Functions Variables Typedefs Enumerator Properties Macros Pages
ARResource+Private.h
Go to the documentation of this file.
1 // ActiveResourceKit ARResource+Private.h
2 //
3 // Copyright © 2011, 2012, Roy Ratcliffe, Pioneering Software, United Kingdom
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EITHER
16 // EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO
18 // EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
19 // OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
22 //
23 //------------------------------------------------------------------------------
24 
26 
27 @class ARHTTPResponse;
28 
29 /*!
30  * @brief Extracts the resource identifier from the given HTTP response.
31  * @details The HTTP response includes a Location header field specifying the
32  * resource's full resource location. Rails places the resource ID at the last
33  * element in the location path. The implementation extracts this element using
34  * a regular expression.
35  * @result Answers an NSNumber numerical identifier based on the response
36  * location field. Answers @c nil if the response does not contain a Location
37  * header, or if the Location field does not match the format @c "/foo/bar/1".
38  */
39 NSNumber *ARIDFromResponse(ARHTTPResponse *response);
40 
41 /*!
42  * @brief Determines whether the HTTP 1.1 specification allows a response to
43  * have a body (see section 4.4.1 of the specification).
44  */
45 BOOL ARResponseCodeAllowsBody(NSInteger code);
46 
48 
49 - (void)updateWithCompletionHandler:(void (^)(ARHTTPResponse *response, NSError *error))completionHandler;
50 
51 - (void)createWithCompletionHandler:(void (^)(ARHTTPResponse *response, NSError *error))completionHandler;
52 
53 /*!
54  * @param response A HTTP response wrapper.
55  * @param attributes Set of attributes decoded from the response body.
56  */
57 - (void)loadAttributesFromResponse:(ARHTTPResponse *)response attributes:(NSDictionary *)attributes;
58 
59 /*!
60  * @brief Answers this resource's element path.
61  * @param options Prefix and query options for overriding the existing resource
62  * prefix options if any.
63  */
64 - (NSString *)elementPathWithOptions:(NSDictionary *)options;
65 
66 //----------------------------------------------------- Active Model Conversions
67 
68 /*!
69  * @brief Enumerates all key attributes.
70  * @result Only answers key attributes if the resource persists. Answers @c nil
71  * otherwise since key attributes only logically exist when the resource begins
72  * to persist.
73  */
74 - (NSArray *)toKey;
75 
76 - (NSString *)toParam;
77 
78 @end