ActiveResourceKit  v1.2 (498.0)
 All Classes Files Functions Variables Typedefs Enumerator Properties Macros Pages
Instance Methods | List of all members
NSEntityDescription(ActiveResource) Category Reference

#import <NSEntityDescription+ActiveResource.h>

Instance Methods

(NSDictionary *) - propertiesFromResource:
 Derives attributes from a given resource using this entity description's attributes.
 
(NSDictionary *) - attributesFromObject:
 Answers a dictionary of Active Resource-style attributes derived from the given object.
 

Detailed Description

Definition at line 29 of file NSEntityDescription+ActiveResource.h.

Method Documentation

- (NSDictionary *) attributesFromObject: (NSObject *)  object

Answers a dictionary of Active Resource-style attributes derived from the given object.

Performs reverse-date conversions: from NSDate to RFC 3339-formatted strings suitable for Rails applications. The method iterates through all attributes, attributes only, no relationships. The implementation uses Key-Value Coding to access the given object. For date attributes, it converts from NSDate to RFC 3339 date-time strings. The resulting dictionary of attributes keys by Rails-convention attribute names, i.e. underscored keys rather than camel-cased keys. Use the results for Active Resource attributes, not for Core Data attributes.

Definition at line 51 of file NSEntityDescription+ActiveResource.m.

- (NSDictionary *) propertiesFromResource: (ARResource *)  resource

Derives attributes from a given resource using this entity description's attributes.

Performs date conversions, using the managed object's entity description to discover attributes. This approach makes an important assumption: that your managed-object model represents the Active Resource schema, or at least part of the schema. There is only one difference: naming convention. The Core Data schema uses camel-case; the resource schema uses underscored names. This method does not validate the schema however. It silently ignores resource attributes that do not appear in the managed-object model.

The method does not handle relationships, only attributes. At this point in the class hierarchy, the method cannot resolve relationships. Resolution requires assumptions about how Core Data relations map to Active Resource relations, and vice versa. Typically this occurs by accessing the foreign key for to-one associations or accessing resources at a remove sub-path in the case of to-many associations. Either way, such mapping must assume things about the Core Data and Active Resource idioms and their interaction.

Definition at line 34 of file NSEntityDescription+ActiveResource.m.


The documentation for this category was generated from the following files: