New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hstore-attributes

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hstore-attributes

  • 0.0.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

HstoreAttributes

HstoreAttributes is a small extension on top of activerecord-postgres-hstore, which creates "fake" attributes that map into the hstore hash. By defining these attributes you get automatic validations and type casting. The approach is very similar to the ActiveRecord::Store feature, yielding better query and index performance in comparison to simple hash-to-yml-string usage.

A small example:

class Product < ActiveRecord::Base
  # hstore column is named 'properties'
  hstore :properties, :accessors => { :width => :integer, :height => :integer, :color => :string }
  
  # if you want to dump strings only:
  hstore :properties, :accessors => [:color, :other_property, :third_property]
  
  validates_numericality_of :weight
  
  #  ...
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

Usage

Usage should be pretty straightforward as shown in the example. Be sure to create a hstore column that takes the mapped attributes. Please note that this works for postgresql databses only.

See: https://github.com/softa/activerecord-postgres-hstore

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

FAQs

Package last updated on 04 Mar 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc