hstorable 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -26
- data/hstorable.gemspec +2 -2
- data/lib/hstorable/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61012f48a37ef9165d01ac0ee19e0a451c59110e
|
4
|
+
data.tar.gz: 005f22f6a3f406406d8cbcb2620c3badc9dae427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dceb7bbd6b653c4c001419299f359c1ee904dee3dc93dcee5bb053db2f882565c4d122cf8140b07d19c83e03bc8f0e2afde57a3235a721ad3647342129645c29
|
7
|
+
data.tar.gz: aa61c0049e5889e0c61f5146f0afd017e94c92d91a984cb2602090add1b1ce7d9cd5b6e5be780f77708616c5d5eb32fcd165e913fc22270c9e4b4aa6f082a9cc
|
data/README.md
CHANGED
@@ -4,15 +4,37 @@ This gem simplifies working wih fields stored using Hstore
|
|
4
4
|
|
5
5
|
## How to use
|
6
6
|
|
7
|
-
|
7
|
+
To use hstorable you should add this line to your Gemfile:
|
8
|
+
|
9
|
+
```
|
10
|
+
gem 'hstorable', '~> 0.0.2'
|
11
|
+
```
|
12
|
+
|
13
|
+
Note, this gem depends on hsore extension of PostgreSQL. So, you should create this extension in your db:
|
14
|
+
|
15
|
+
```SQL
|
16
|
+
CREATE EXTENSION hstore;
|
17
|
+
```
|
18
|
+
|
19
|
+
It is pertty easy to use HStorable with STI in RoR. First of all you shoud create table like this:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
create_table :wrappers do |t|
|
23
|
+
t.hstore :properties, default: '', null: false
|
24
|
+
t.string :type, null: false
|
25
|
+
t.timestamps
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
That's all. Now you can use hstorable to solve your problems.
|
8
30
|
|
9
31
|
```ruby
|
10
32
|
|
11
|
-
class Api::
|
12
|
-
|
33
|
+
class Api::Wrapper < ActiveRecord::Base
|
34
|
+
include Hstorable
|
13
35
|
end
|
14
36
|
|
15
|
-
class Api::OneApiWrapper < Api::
|
37
|
+
class Api::OneApiWrapper < Api::Wrapper
|
16
38
|
hstore_simple :properties, name: 'consumer_key'
|
17
39
|
hstore_simple :properties, name: 'consumer_secret'
|
18
40
|
hstore_simple :properties, name: 'api_version', default: '26.0'
|
@@ -29,30 +51,17 @@ class Api::AnotherApiWrapper < Api::BaseWrapper
|
|
29
51
|
end
|
30
52
|
```
|
31
53
|
|
32
|
-
Different types of models with different set of fields will be stored in one table.
|
33
|
-
|
34
|
-
## Installation
|
35
|
-
|
36
|
-
Add this line to your application's Gemfile:
|
37
|
-
|
38
|
-
gem 'hstorable'
|
39
|
-
|
40
|
-
And then execute:
|
41
|
-
|
42
|
-
$ bundle
|
54
|
+
Different types of models with different set of fields will be stored in one table. And you can use it as ordinary model's properties.
|
43
55
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
56
|
+
```ruby
|
57
|
+
api = Api::OneApiWrapper.new(consumer_key: '743b57c3120b49b42588011066411d98', cosumer_secret: '743b57c3120b49b42588011066411d98')
|
58
|
+
api.cosumer_key # => 743b57c3120b49b42588011066411d98
|
59
|
+
api.cosumer_secret # => 743b57c3120b49b42588011066411d98
|
60
|
+
api.save
|
61
|
+
api.update cosumer_key: 2afc9269f7ceb78533d6a2e2d72a14f9
|
62
|
+
```
|
50
63
|
|
51
|
-
|
52
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
-
5. Create new Pull Request
|
64
|
+
Cool, isn't?
|
56
65
|
|
57
66
|
## License
|
58
67
|
|
data/hstorable.gemspec
CHANGED
@@ -13,13 +13,13 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "http://hstorable.kimrgrey.org/"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files = `git ls-files`.split(
|
16
|
+
spec.files = `git ls-files`.split("\n")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
-
spec.add_development_dependency "rake", "~> 10.3
|
22
|
+
spec.add_development_dependency "rake", "~> 10.3"
|
23
23
|
|
24
24
|
spec.add_runtime_dependency "pg", "0.17.1"
|
25
25
|
end
|
data/lib/hstorable/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hstorable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Tsvetkov
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 10.3
|
33
|
+
version: '10.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 10.3
|
40
|
+
version: '10.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pg
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|