redijson_models 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Readme.md +33 -0
- data/lib/redijson_models.rb +7 -2
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ac69b8eba7f8d906969f5fe6853091b56b272631d024e0e5d3d7356ad6306d4
|
4
|
+
data.tar.gz: bd4a54d09a8309c955d2886926a86f4c0409954fdd9674a441f60166bdf641d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3ce08234eb353464d9a0b41ca76c7927ad49dd2717ca0dcf64d1d49cd6c4c83259c14df5135907572d85a2f8663e75cbf8809899ffecdbcbb4208b109112eb4
|
7
|
+
data.tar.gz: 121ed8f4e9ff55ddad04307be04cff3d66c03a8e5fd1e24ca4a61f1779ce35963098eeb5479e3ff8a7d51e3b73202d8f1cf888df488ffca0401fc6ec2340d4cf
|
data/Readme.md
CHANGED
@@ -2,6 +2,19 @@
|
|
2
2
|
|
3
3
|
Document-like ORM based on Redis key value store - uses Redis Re-JSON for full json manipulation
|
4
4
|
|
5
|
+
### Install
|
6
|
+
|
7
|
+
Add to your gemfile:
|
8
|
+
|
9
|
+
```rb
|
10
|
+
gem 'redijson_models', '~> 0.8.1'
|
11
|
+
```
|
12
|
+
|
13
|
+
Or without bundler, run in your shell:
|
14
|
+
|
15
|
+
gem i redijson_models
|
16
|
+
|
17
|
+
|
5
18
|
### Requirements
|
6
19
|
|
7
20
|
- Redis (v4+)
|
@@ -63,6 +76,26 @@ docker-compose up
|
|
63
76
|
Which use the docker-compose.yml to start your redis.
|
64
77
|
|
65
78
|
|
79
|
+
### Set up your Redis and RJSON
|
80
|
+
|
81
|
+
```rb
|
82
|
+
# sample environment setup
|
83
|
+
require 'bundler'
|
84
|
+
Bundler.require :default
|
85
|
+
|
86
|
+
# setup redis
|
87
|
+
R = Redis.new
|
88
|
+
|
89
|
+
# load and configure redis with rejson models
|
90
|
+
include RediJsonModels
|
91
|
+
RJ.configure redis: R
|
92
|
+
|
93
|
+
class Document
|
94
|
+
# ...
|
95
|
+
end
|
96
|
+
```
|
97
|
+
|
98
|
+
|
66
99
|
### Run specs
|
67
100
|
|
68
101
|
(you need to run a local redis + rejson service - explained above)
|
data/lib/redijson_models.rb
CHANGED
@@ -94,9 +94,14 @@ module RediJsonModels
|
|
94
94
|
|
95
95
|
def save
|
96
96
|
klass = self.class
|
97
|
-
id = klass.send :incr
|
98
97
|
attrs = attributes
|
99
|
-
|
98
|
+
id = attrs[:id]
|
99
|
+
unless id
|
100
|
+
entry_id = klass.send :incr
|
101
|
+
attrs.merge! "id" => entry_id
|
102
|
+
id = entry_id
|
103
|
+
end
|
104
|
+
|
100
105
|
RJ["#{self.class.resource}:#{id}"] = attrs
|
101
106
|
self.id = id
|
102
107
|
self
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redijson_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- makevoid
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|