Shopify/identity_cache — pull request #131 by dylanahsmith (2014-03-05 01:11:50+00:00)
Title: Use symbols for embed option values for clarify and future compatibility.

@camilo & @fbogsany

## Problem

```ruby
cache_has_many :association, :embed => false
```

makes it seem as if nothing will be embedded for this cached association. However, this is not true. This will actually embed the ids for the association.

This misconception led to a regression in the cache key format which was discussed and fixed in pull #126 and introduced in pull #120. We should make the code clear that ids are being embedded to avoid misconceptions for developers of this library and for developers using this library which could easily have the same misconception.

## Solution

Change the API to take a symbol as the embed option as follows
```ruby
cache_has_many :association, :embed => :ids
```
which makes the behaviour clear from reading the code.

I believe the `:embed => true` option for cache_has_many and cache_has_one also suffers from possible misconceptions. This option isn't clear that we are recursively embedding the associated records without reading the README. This pull request solves uses `:embed => :recursively` to make this abundantly clear, although more verbose.

A deprecation warning will be printed if the old options are used.

```ruby
cache_belongs_to :association, :embed => false
```
was intentionally unchanged, since the id is a part of the record itself, and therefore not a denormalization in the cached value.

## Future Work

The code should also be updated to avoid referring to id embedded associations as a normalized association.