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

#import <ARIncrementalStore+Private.h>

Instance Methods

(NSManagedObjectID *) - objectIDForResource:withContext:
 Using a particular context, derives a managed-object identifier based on a resource's element name and its primary key.
 
(NSManagedObjectID *) - objectIDForCachedResource:withContext:
 Answers the object identifier for a given resource after caching the resource against its object identifier.
 
(ARResource *) - cachedResourceForObjectID:error:
 Converts an object identifier to an active resource.
 
(uint64_t) - versionForResource:
 Answers a 64-bit version number derived from the given resource.
 
(void) - refreshObject:
 Refreshes an object in the incremental store cache.
 
(NSDictionary *) - foreignKeysForObject:resource:
 Resolves relationships.
 

Detailed Description

Definition at line 29 of file ARIncrementalStore+Private.h.

Method Documentation

- (ARResource *) cachedResourceForObjectID: (NSManagedObjectID *)  objectID
error: (NSError **)  outError 

Converts an object identifier to an active resource.

The conversion occurs using the resource cache, if the resource currently exists in the cache (a cache hit). Otherwise the implementation first loads the cache with the resource using the given object identifier (a cache miss). Uncached resources become cached before the method returns.

Extends class ARIncrementalStore.

Definition at line 46 of file ARIncrementalStore+Private.m.

- (NSDictionary *) foreignKeysForObject: (NSManagedObject *)  object
resource: (ARResource *)  resource 

Resolves relationships.

Picks out the to-one associations. Is there a foreign key with a matching to-one relationship? Looks for a matching foreign key within the resource for each to-one relationship. If the foreign key does not exist but the to-one relationship does, then resolves the relationship at the server side by assigning the foreign key to the relationship destination's object reference, its resource identifier. Collects such foreign key attributes first because there could be multiple. Merge and save them.

Ignores to-many associations. Rails will handle that.

Extends class ARIncrementalStore.

Definition at line 91 of file ARIncrementalStore+Private.m.

- (NSManagedObjectID *) objectIDForCachedResource: (ARResource *)  resource
withContext: (NSManagedObjectContext *)  context 

Answers the object identifier for a given resource after caching the resource against its object identifier.

Extends class ARIncrementalStore.

Definition at line 39 of file ARIncrementalStore+Private.m.

- (NSManagedObjectID *) objectIDForResource: (ARResource *)  resource
withContext: (NSManagedObjectContext *)  context 

Using a particular context, derives a managed-object identifier based on a resource's element name and its primary key.

Derives the entity name from the resource element name.

Extends class ARIncrementalStore.

Definition at line 32 of file ARIncrementalStore+Private.m.

- (void) refreshObject: (NSManagedObject *)  object

Refreshes an object in the incremental store cache.

Parameters
objectThe object to refresh.

The given object disappears from the resource cache and becomes a fault. Subsequent attempts to access the object will refetch its resource attributes. This happens when objects insert. Inserted objects become unrealised because the remote server typically validates and further updates the inserted resource, e.g. by setting its update-at date. It also occurs when you update an object, for the same reason. Object deletion also refreshes the cache; the deleted resource disappears from the cache and the object becomes a fault before disappearing from the managed-object context as all deleted objects do.

Extends class ARIncrementalStore.

Definition at line 85 of file ARIncrementalStore+Private.m.

- (uint64_t) versionForResource: (ARResource *)  resource

Answers a 64-bit version number derived from the given resource.

Uses the updated-at date-time as the version number. Converts the update-at date to seconds since the reference date. This amounts to a big version number, but the version number allows for 64 bits of unsigned integer width.

Also makes an assumption about the updated-at dates: that they always exceed midnight 1st January 2001, the reference point. If they precede that point, then the reference-relative time interval becomes negative, the signed interval wraps the unsigned 64-bit version and version numbers start counting down. This is not what Core Data will expect.

The implementation multiplies the time interval by 1,000 in order to allow for rare sub-second updates, if the server-side includes date-time at sub-second resolutions. RFC 3339 date-time formats allow for sub-second accuracy.

Extends class ARIncrementalStore.

Definition at line 70 of file ARIncrementalStore+Private.m.


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