basho/cuttlefish — pull request #89 by joedevivo (2013-12-13 16:52:31+00:00)
Title: Extended datatypes

This one's for you @evanmcc and @jtuple

Now, when writing a schema, you can add multiple datatypes. Here's how it works:

In a mapping, `{datatype, Type}` still works as it used to, but if you want, you can replace Type with a List of types.

Example: anti_entropy.expire

```erlang
{mapping, "anti_entropy.expire", "riak_kv.anti_entropy.expire", [
{datatype, [{duration, ms}, {atom, never}]}
]}.
```

now if you set something like `anti_entropy.expire = right_away` it will try converting "right_away" into a duration first. When that doesn't work, it'll try converting it to an atom and then compare to 'never'. Only if these all fail will it produce an error, and the first one to pass is the one it uses.

You can put any datatype that currently exists, and I've added a few more. These extended types are single instances of a type, like `{atom, never}`, which only allows the atom 'never'.

I hope that makes sense. Better documentation for this will come next week on the cuttlefish wiki.