hstore_utils 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/hstore_utils.gemspec +24 -0
- data/lib/hstore_utils/version.rb +3 -0
- data/lib/hstore_utils.rb +24 -0
- metadata +56 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "hstore_utils/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "hstore_utils"
|
7
|
+
s.version = HstoreUtils::VERSION
|
8
|
+
s.authors = ["Luis Cruz", "Martina Simicic"]
|
9
|
+
s.email = ["luis.cruz@teclacolorida.com", "martina.simicic@escolinhas.pt"]
|
10
|
+
s.homepage = "https://github.com/kiddosware/hstore_utils"
|
11
|
+
s.summary = %q{Some utilities to make hstore easier.}
|
12
|
+
s.description = %q{This gem is based on the railscast #345 HStore, that introduces the use of the HStore type for PostgreSQL. With this gem you can declare the key/values inside your Hstore attribute as attribute accessors :) Contributions are welcome! Note: It assumes you have the activerecord-postgres-hstore gem installed.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "hstore_utils"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
data/lib/hstore_utils.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "hstore_utils/version"
|
2
|
+
|
3
|
+
module HstoreUtils
|
4
|
+
def hstore_accessor(*args)
|
5
|
+
hstore_field = args[0]
|
6
|
+
args[1..-1].each do |key|
|
7
|
+
attr_accessible key
|
8
|
+
#scope "has_#{key}", lambda { |value| where("#{hstore_field} @> (? => ?)", key, value) }
|
9
|
+
|
10
|
+
define_method(key) do
|
11
|
+
send(hstore_field) && eval("#{hstore_field}[\"#{key}\"]")
|
12
|
+
end
|
13
|
+
|
14
|
+
define_method("#{key}=") do |value|
|
15
|
+
self.send("#{hstore_field}=", (self.send(hstore_field) || {}).merge(key.to_s => value))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# include the extension
|
24
|
+
Class.send(:include, HstoreUtils)
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hstore_utils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Luis Cruz
|
9
|
+
- Martina Simicic
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-05-18 00:00:00.000000000Z
|
14
|
+
dependencies: []
|
15
|
+
description: ! 'This gem is based on the railscast #345 HStore, that introduces the
|
16
|
+
use of the HStore type for PostgreSQL. With this gem you can declare the key/values
|
17
|
+
inside your Hstore attribute as attribute accessors :) Contributions are welcome!
|
18
|
+
Note: It assumes you have the activerecord-postgres-hstore gem installed.'
|
19
|
+
email:
|
20
|
+
- luis.cruz@teclacolorida.com
|
21
|
+
- martina.simicic@escolinhas.pt
|
22
|
+
executables: []
|
23
|
+
extensions: []
|
24
|
+
extra_rdoc_files: []
|
25
|
+
files:
|
26
|
+
- .gitignore
|
27
|
+
- Gemfile
|
28
|
+
- Rakefile
|
29
|
+
- hstore_utils.gemspec
|
30
|
+
- lib/hstore_utils.rb
|
31
|
+
- lib/hstore_utils/version.rb
|
32
|
+
homepage: https://github.com/kiddosware/hstore_utils
|
33
|
+
licenses: []
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubyforge_project: hstore_utils
|
52
|
+
rubygems_version: 1.8.10
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: Some utilities to make hstore easier.
|
56
|
+
test_files: []
|