Update README.md
Chained fetch request builder (ObjectiveRelation)

This commit provides to ObjectiveRecord what Arel[1] provided to Active
Record.

[1]: https://github.com/rails/arel

It simplifies the interface by using a chained request builder. Instead
of:

  [Person where:@{@"firstName": @"Stephen"} order:@"lastName" limit:@5];

We can use:

  [[[Person where:@"firstName = %@", @"Stephen"] order:@"lastName"] limit:5];

Because of chaining, we can remove most of the methods that build
complex fetch requests all at once, and we can support features that
were previously omitted, like offset (perhaps due to the number of
method signature permutations required to make them work).

Even +countWhere: can be removed:

  [[Person where:@"firstName = %@", @"Stephen"] count];

Each step in the chain returns a lazy-loading fetch request. So you can
store a base request and build on it in different ways. E.g.,

  // Create 2 people in a private context
  id privatePeople = [Person inContext:privateContext];
  [privatePeople create:@{@"firstName": @"Marin"}];
  [privatePeople create:@{@"firstName": @"Stephen"}];

  // Pagination
  id page = [Person limit: 5];
  // ...
  page = [page offset:[page offset] + [page limit]];

A fetch request is not executed before you ask for data that would
require a fetch, e.g. by iterating, fetching a specific result, or a
count.

Fetch request builders conform to NSFastEnumeration and forward array
selectors to the result set, so act on them as you would act on the
final NSArray:

  for (Person *person in [Person all]) {
    // ...
  }

  [[Person where:@"admin = NO"] setValue:@YES forKey:@"admin"];

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Add updateAll:

Quickly allows records to be updated via scope.

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Reorganize ActiveRecord/Relation methods

Organize by:

 - Building fetch requests
 - Executing fetch requests
 - Inserting entities
 - Modifying entities
 - Deleting entities

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Expose .limit and .offset on ObjectiveRelation

Good for public introspection (for, e.g., pagination).

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Support old NSManagedObject methods (via deprecation)

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Add LICENSE to individual files

Also add LICENSE information to the README (and update the LICENSE
file).

Should make things friendlier for those that care.

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Use __deprecated consistently

It's shorter, so let's prefer it.

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Better KVC support for `update:`

If we use setPrimitiveValue:forKey:, and wrap the block that assigns
everything with calls to willChangeValueForKey: and
didChangeValueForKey:, we can ensure that observers are acting on the
full dataset at once.

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Move date formatter to its one concern

No need for the method wrapper when we're only calling it in one place.

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Improve NSManagedObject+Mappings HeaderDoc

More description. More param. More return.

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Document +[NSManagedObjectContext defaultContext]

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Remove unused import

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Update ObjectiveRelation methods to be more descriptive

Entity is usually used to describe an NSEntityDescription, so let's use
ManagedObjectClass, instead.

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Use subscripting whenever possible

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Remove unneeded nil check

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Support setting objects directly in to-many relationships

By making this method more recursive, and checking if the value is
already the correct class, we can be sure that doing the following won't
break:

  Person *employee = [Person create];
  Person *manager = [Person create:@{
    @"employees": @[employee]
  }];

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Relationship relation builders

Adds support for -[NSManagedObject relationWithName:], which returns an
ObjectiveRelation for to-many relationships that have an inverse
relationship that can be introspected.

These relations will forward selectors to the original (mutable) set
where applicable. E.g.,

  [[person relationWithName:@"employees"] addObject:employee];

If the dynamic property defined for one of these relationships is of
type id, it will return an ObjectiveRelation, instead:

  @interface Person : NSManagedObject
  @property (nonatomic, strong) id employees;
  @end

  @implementation Person
  @dynamic employees;
  @end

  Person *person = [Person find:@"firstName = %@", @"Stephen"];
  // Fetch through relationship
  [person.employees where:@"firstName = %@", @"Marin"];
  // Create through relationship
  [person.employees create:@{@"firstName": @"Dave"}];

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Consistency

This project appears to prefer listing properties in the following
order:

 - readonly/readwrite
 - assign/weak/strong/retain/copy
 - atomic/nonatomic

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Whitespace adjustments

Signed-off-by: Stephen Celis <stephen@stephencelis.com>