<commit_before># Storex

ActiveRecord::Base.store_accessor gives you accessors specific to
PostgreSQL's `hstore` for storing hashes into a single column
(See [ActiveRecord::Store](http://api.rubyonrails.org/classes/ActiveRecord/Store.html)).

Storex builds on top of that so that you can define more options such as:
* default values
* type (`String`, `Integer`)

Currently this gem uses [virtus](see https://github.com/solnic/virtus)
so you can pass options that is accepted by [Virtus::Extensions#attribute](https://github.com/solnic/virtus#using-virtus-with-classes)

## Dependencies
  * PostgreSQL
  * ruby 2.1 (but may work on earlier versions)
  * rails 4.0

## Installation

Just add `gem 'storex'` in your Gemfile and `bundle install`.

## Usage

```ruby
# create a migration that enables hstore e.g.
# db/migrate/timestamp_install_hstore.rb
class InstallHstore < ActiveRecord::Migration
  def change
    enable_extension :hstore
  end
end

# then create another migration that adds an hstore column e.g.
# db/migrate/timestamp_create_books.rb
class CreateBooks < ActiveRecord::Migration
  def change
    create_table :books do |t|
      t.hstore :data
    end
  end
end

# run `rake db:migrate` and then in your model e.g.
# app/models/book.rb
class Book < ActiveRecord::Base

  include Storext
  store_attributes :data do
    author String
    title String, default: "Great Voyage"
    available Axiom::Types::Boolean, default: true
    copies Integer, default: 0
  end
  store_attribute :data, :hardcover, Axiom::Types::Boolean
  store_attribute :data, :alt_name

end
```
## How to run the test suite
<commit_msg>Differentiate ways to define store attributes<commit_after># Storex

ActiveRecord::Base.store_accessor gives you accessors specific to
PostgreSQL's `hstore` for storing hashes into a single column
(See [ActiveRecord::Store](http://api.rubyonrails.org/classes/ActiveRecord/Store.html)).

Storex builds on top of that so that you can define more options such as:
* default values
* type (`String`, `Integer`)

Currently this gem uses [virtus](see https://github.com/solnic/virtus)
so you can pass options that is accepted by [Virtus::Extensions#attribute](https://github.com/solnic/virtus#using-virtus-with-classes)

## Dependencies
  * PostgreSQL
  * ruby 2.1 (but may work on earlier versions)
  * rails 4.0

## Installation

Just add `gem 'storex'` in your Gemfile and `bundle install`.

## Usage

```ruby
# create a migration that enables hstore e.g.
# db/migrate/timestamp_install_hstore.rb
class InstallHstore < ActiveRecord::Migration
  def change
    enable_extension :hstore
  end
end

# then create another migration that adds an hstore column e.g.
# db/migrate/timestamp_create_books.rb
class CreateBooks < ActiveRecord::Migration
  def change
    create_table :books do |t|
      t.hstore :data
    end
  end
end

# run `rake db:migrate` and then in your model e.g.
# app/models/book.rb
class Book < ActiveRecord::Base

  include Storext

  # You can define attributes on the :data hstore column like this:
  store_attributes :data do
    author String
    title String, default: "Great Voyage"
    available Axiom::Types::Boolean, default: true
    copies Integer, default: 0
  end

  # Or you can define attributes like this:
  store_attribute :data, :hardcover, Axiom::Types::Boolean
  store_attribute :data, :alt_name

end
```
## How to run the test suite

{'fraction_non_alphanumeric': 0.09340011785503831, 'fraction_numerical': 0.0029463759575721863, 'mean_word_length': 4.354889589905363, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1807042', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1037, 'n_words': 363}