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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30357bca904d68eeda27241f13af2944be8b77dad3ec7e80dcad48d66969cdbf
4
- data.tar.gz: e0693e800d8ac4f3fd6821d5af3491c8b7b6d4cd346e2cff555a76c08feceaab
3
+ metadata.gz: 3ac69b8eba7f8d906969f5fe6853091b56b272631d024e0e5d3d7356ad6306d4
4
+ data.tar.gz: bd4a54d09a8309c955d2886926a86f4c0409954fdd9674a441f60166bdf641d2
5
5
  SHA512:
6
- metadata.gz: 746c2b403029daef1ed4b4dc157b05b365ead7234fd349061cc34c3deec0228638102238b3ba83add93988b9a0a7b5e87d55bb521b5bc0e54ce9bed8852e6995
7
- data.tar.gz: d36d18d784dcbee0a58f5c44fb9caf50cf1690dca095649a29821e2009970e21def066e8cb4c420e3d734cde7eb6b21e98cdda139ea0bddf2022ea93b12afa50
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)
@@ -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
- attrs.merge! "id" => id
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
@@ -1,3 +1,3 @@
1
1
  module RediJsonModels
2
- VERSION = "0.8.1"
2
+ VERSION = "0.9.0"
3
3
  end
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.8.1
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-14 00:00:00.000000000 Z
11
+ date: 2020-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis