[MODEL] Added, that "raw" response from Elasticsearch is wrapped in Hashie::Mash for easier access

    response = Article.search query: { match: { title: { query: 'test' } } },
                              aggregations: { dates: { date_histogram: { field: 'created_at', interval: 'hour' } } }

    assert_equal 2, response.response.aggregations.dates.buckets.first.doc_count
    # => 2
[STORE] Added the first version of the ActiveRecord-based model persistence

Using the `Elasticsearch::Persistence::Repository` from previous commits,
this patch adds support for the ActiveRecord pattern of persistance
for Ruby objects in Elasticsearch.

The goal is to have a 1:1 implementation to the ActiveRecord::Base implementation,
allowing to use it as a drop-in replacement for similar OxMs in Rails applications,
with minimal changes to the model definition and application code.

The model implementation uses [Virtus](https://github.com/solnic/virtus)
for handling the model attributes, and [ActiveModel](https://github.com/rails/rails/tree/master/activemodel)
for validations, callbacks, and similar model-related features.

Example:
--------

require 'elasticsearch/persistence/model'

class Person
  include Elasticsearch::Persistence::Model

  settings index: { number_of_shards: 1 }

  attribute :name, String,
            mapping: { fields: {
              name: { type: 'string', analyzer: 'snowball' },
              raw:  { type: 'string', analyzer: 'keyword' }
            } }

  attribute :birthday,   Date
  attribute :department, String
  attribute :salary,     Integer
  attribute :admin,      Boolean, default: false

  validates :name, presence: true

  before_save do
    puts "About to save: #{self}"
  end
end

Person.gateway.create_index! force: true

person = Person.create name: 'John Smith', salary: 10_000
About to save: #<Person:0x007f961e89f010>
=> #<Person:0x007f961e89f010 ...>

person.id
=> "zNf3yxZDQsOTZfNfTX4E5A"

person = Person.find(person.id)
=> #<Person:0x007f961cf1f478 ... >

person.salary
=> 10000

person.increment :salary
=> { ... "_version"=>2}
person.salary
=> 10001

person.update admin: true
=> { ... "_version"=>3}

Person.search('smith').to_a
=> [#<Person:0x007f961ebc5b90 ...>]
[STORE] Added a rudimentary support for extracting date/time from Rails forms

  Started POST "/articles" for 127.0.0.1 at 2014-04-28 19:03:35 +0200
  Processing by ArticlesController#create as HTML
    Parameters: {"utf8"=>"✓", "authenticity_token"=>"RS4ZqcdL8SPbo0g9kNzPG24D+PpspIit4SyOXcLhYXk=", "article"=>{"title"=>"With Date", "content"=>"", "published_on(1i)"=>"2014", "published_on(2i)"=>"4", "published_on(3i)"=>"1", "published_on(4i)"=>"15", "published_on(5i)"=>"00"}, "commit"=>"Create Article"}

  POST http://localhost:9250/articles/article [status:201, request:0.155s, query:n/a]
  > {"created_at":"2014-04-28T17:03:35.190+00:00","updated_at":"2014-04-28T17:03:35.190+00:00","title":"With Date","content":"","published_on":"2014-04-01T15:00:00.000+00:00"}

This has to be refactored into a Realtie
[STORE] Added `MyModel.all` finder method

    Person.all.to_a

    # 2014-05-05 15:02:24 +0200: GET http://localhost:9250/people/person/_search [status:200, request:0.047s, query:0.024s]
    # 2014-05-05 15:02:24 +0200: > {"query":{"match_all":{}},"size":10000}
    # 2014-05-05 15:02:24 +0200: < # {"took":24,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":100,"max_score":1.0,"hits":[ .... ]}}
    # => [#<Person:0x007ff1d8fb04b0 ... ]
[STORE] Added missing test for Elasticsearch::Persistence::Model::Utils.lookup_type
[STORE] Added code annotations across the Persistence::Model codebase
[STORE] Added the `find_in_batches` method for models

    Person.find_in_batches { |batch| puts batch.map(&:name) }

See: http://api.rubyonrails.org/classes/ActiveRecord/Batches.html#method-i-find_in_batches
[STORE] Added, that `find_in_batches` returns an Enumerator when the block is not passed

Example:

    Person
      .find_in_batches(size: 100)
      .each { |batch| puts batch.results.map(&:name) }
    # => Test 0
         Test 1
         Test 2
         Test 3
         Test 4

See:

* http://ruby-doc.org/core-2.1.2/Object.html#method-i-to_enum
* http://blog.arkency.com/2014/01/ruby-to-enum-for-enumerator/
[STORE] Added the `find_each` method for models

    Person.find_each { |person| puts person.name }

    # # GET http://localhost:9200/people/person/_search?scroll=5m&search_type=scan&size=20
    # # GET http://localhost:9200/_search/scroll?scroll=5m&scroll_id=c2Nhbj...
    # Test 0
    # Test 1
    # Test 2
    # ...
    # # GET http://localhost:9200/_search/scroll?scroll=5m&scroll_id=c2Nhbj...
    # Test 20
    # Test 21
    # Test 22

See: http://api.rubyonrails.org/classes/ActiveRecord/Batches.html#method-i-find_each
[STORE] Added a custom `inspect` methods to model

    person.inspect
    #<Person {id: "NkltJP5vRxqk9_RMP7SU8Q", ..., name: "Test 100", ...}>
[STORE] Added, that model can be created with a custom ID, and _index/_type/_version are set per model instance

Previously, it was not possible to set a custom ID for a model, when creating/saving it.
This patch fixes this ridiculous oversight.

Also, when the model is saved into a *different* index than the class-level `index_name`, the `_index`
method returns it correctly. Also applies to `_type` and `_version`.
[STORE] Added a `count` method to the repository and model

  repository.count
  Person.count
[STORE] Allow accessing the raw hit directly from result

    people = Person.search query: { match: { name: 'smith' } },
                           highlight: { fields: { name: {} } }

    people.first.hit.highlight['name'].first
    # => ["John <em>Smith</em>"]
[STORE] Added an integration test for creating/saving models with custom IDs
[STORE] Added `Model.create_index!` and `Model.refresh_index!` methods (delegated to gateway)
[STORE] Fixed incorrect handling of Rails' form values for `Date`

(Previously, only `DateTime` objects have been working)
[STORE] Added full readme for the "active record" pattern
[STORE] Added a Rails ORM generator for Elasticsearch::Persistence::Model

Usage:

    $  bundle exec rails generate scaffold Person name:String email:String --orm=elasticsearch --force
[STORE] Added the template for generating a full Rails application with persistence model

Usage:

    rails new music --force --skip --skip-bundle --skip-active-record --template /path/to/template.rb
    rails new music --force --skip --skip-bundle --skip-active-record --template https://raw.githubusercontent.com/elasticsearch/elasticsearch-rails/persistence-model/elasticsearch-persistence/examples/music/template.rb
[STORE] Renamed the Sinatra example application folder to "notes", added more info into the README