ActiveResourceKit  v1.2 (498.0)
 All Classes Files Functions Variables Typedefs Enumerator Properties Macros Pages
NSEntityDescription+ActiveResource.h
Go to the documentation of this file.
1 // ActiveResourceKit NSEntityDescription+ActiveResource.h
2 //
3 // Copyright © 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 
25 #import <CoreData/CoreData.h>
26 
27 @class ARResource;
28 
30 
31 /*!
32  * @brief Derives attributes from a given resource using this entity
33  * description's attributes.
34  * @details Performs date conversions, using the managed object's entity
35  * description to discover attributes. This approach makes an important
36  * assumption: that your managed-object model represents the Active Resource
37  * schema, or at least part of the schema. There is only one difference: naming
38  * convention. The Core Data schema uses camel-case; the resource schema uses
39  * underscored names. This method does not validate the schema however. It
40  * silently ignores resource attributes that do not appear in the managed-object
41  * model.
42  *
43  * The method does not handle relationships, only attributes. At this point in
44  * the class hierarchy, the method cannot resolve relationships. Resolution
45  * requires assumptions about how Core Data relations map to Active Resource
46  * relations, and vice versa. Typically this occurs by accessing the foreign key
47  * for to-one associations or accessing resources at a remove sub-path in the
48  * case of to-many associations. Either way, such mapping must assume things
49  * about the Core Data and Active Resource idioms and their interaction.
50  */
51 - (NSDictionary *)propertiesFromResource:(ARResource *)resource;
52 
53 /*!
54  * @brief Answers a dictionary of Active Resource-style attributes derived from
55  * the given object.
56  * @details Performs reverse-date conversions: from @c NSDate to RFC
57  * 3339-formatted strings suitable for Rails applications. The method iterates
58  * through all attributes, attributes only, no relationships. The implementation
59  * uses Key-Value Coding to access the given object. For date
60  * attributes, it converts from @c NSDate to RFC 3339 date-time strings. The
61  * resulting dictionary of attributes keys by Rails-convention attribute names,
62  * i.e. underscored keys rather than camel-cased keys. Use the results for
63  * Active Resource attributes, not for Core Data attributes.
64  */
65 - (NSDictionary *)attributesFromObject:(NSObject *)object;
66 
67 @end