Repository is archived
No commit activity in last 3 years
No release in over 3 years
Provides methods like hstore_reader or hstore_writer for accessing your Hstore data like any other attributes.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.3
>= 0

Runtime

 Project Readme

HstoreAttributes

Provides methods like hstore_reader or hstore_writer for accessing your Hstore data like any other attributes. It also gives you a possibility to typecast the value.

Usage

class Product < ActiveRecord::Base
  extend HstoreAttributes

  # The hstore column is named 'data'
  hstore_accessor :data, :description
  hstore_accessor :data, :price, :tax, type_cast: :to_i
  hstore_accessor :data, :available_from, type_cast: ->(value) { value.to_s.to_date }
end

Installation

Add this line to your application's Gemfile:

gem "hstore_attributes"

And then execute:

$ bundle

Or install it yourself as:

$ gem install hstore_attributes