Use 'href' instead of :href in `present`

Jsonite consistently uses string keys in the presentation methods except
for the `:href` key in links. This comes through as a symbol which,
before calling #to_json, is fine. However, this breaks expectations
given that all other hash keys are strings. We should keep this
consistent and change this key to be a string as well.

Signed-off-by: David Celis <me@davidcel.is>
Refactor configuration

By storing the options instead of generating handlers, we can simply
call an instance method, instead.

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Add `:ignore_nil` option

Fixes #6

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

Jsonite should be smart about not sending `nil` objects to embedded
presenter objects.

Fixes #7

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

Travis' build bots are a little slower than the machines we've been
developing on, so I've made the benchmark test speed requirement a bit
more lenient. We should consider a more testable benchmark, though (by
complexity and number of iterations rather than a static amount of time.

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Shorten up README example

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

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

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

Let's use keyword arguments. It'll make things simpler when we add more
to the Jsonite.property declaration.

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

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

Allows us to use Jsonite.present and hand it any registered resource to
be presented.

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

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Track property types when given

Allows for introspection (e.g., for documentation)

We could potentially warn if the value is of the wrong type during
presentation, but this causes complications for, e.g.,
Date/Time/DateTime.

Fixes #12

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Add support for Jsonite(Resource)

It allows us to declare the presented resource class up front:

  class UserPresenter < Jsonite(User)
    property :name
  end
  Jsonite.present(User.first) # => {"name"=>"Stephen"}

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Add mapping cache for resource subclass presentation

E.g.:

  class UserPresenter < Jsonite(User)
    property :name
  end

  class Admin < User
    # ...
  end

  Jsonite.present(Admin.first) # => {"name"=>"Stephen"}

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Just pass the resource through if no presenter subclass is found

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Document Jsonite() method

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Expose registered resource classes (for introspection)

Signed-off-by: Stephen Celis <stephen@stephencelis.com>
Don't bother converting strings

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

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