post_json 1.0.7 → 1.0.8
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 +4 -2
- data/lib/post_json/concerns/settings_methods.rb +19 -0
- data/lib/post_json/version.rb +1 -1
- data/spec/models/collection_spec.rb +44 -17
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe619530d2d95e8da438a6ff399d7d2972188114
|
4
|
+
data.tar.gz: a65c7296009eef778e19ae160d174ebea791d5da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24b5cda73ffcb9f0eeecd34dfe419112864eb91ea3e88e918a4696066744e076a369d174dbfdbcadab5d16308535b18d863dfe90302b1d84677ffe3745a46306
|
7
|
+
data.tar.gz: a35b4b760040c191956e2358199c27a90d5a2ec53e39df4b7756d1136e1e8dd31dc6ba38624c0f80709807d24971936a7241449597833fb244346323d9f1c4f0
|
data/README.md
CHANGED
@@ -196,7 +196,7 @@ You can adjust the settings:
|
|
196
196
|
|
197
197
|
You might already know this about User Interfaces, but it is usual considered good practice if auto-complete responses are served to the user within 100 milliseconds. Other results are usual okay within 500 milliseconds. So leave room for application processing and network delay.
|
198
198
|
|
199
|
-
Do not set create_dynamic_index_milliseconds_threshold too low as PostJson will try to create an index for every query
|
199
|
+
Do not set create_dynamic_index_milliseconds_threshold too low as PostJson will try to create an index for every query. Like a threshold of 1 millisecond will be less than the duration of almost all queries.
|
200
200
|
|
201
201
|
## Primary Keys
|
202
202
|
|
@@ -213,7 +213,7 @@ But you also set the primary key yourself:
|
|
213
213
|
Notice the primary key is downcased when doing a query or finding records:
|
214
214
|
|
215
215
|
found = Person.where(id: "JOhN DoE").first
|
216
|
-
puts found
|
216
|
+
puts found.attributes
|
217
217
|
# {"id"=>"John Doe", "version"=>1, "created_at"=>"2013-10-22T10:42:26.190Z", "updated_at"=>"2013-10-22T10:42:26.190Z"}
|
218
218
|
|
219
219
|
found_again = Person.find("JOhN DoE")
|
@@ -229,6 +229,8 @@ A few things we will be working on:
|
|
229
229
|
- Automatic deletion of dynamic indexes when unused for a period of time.
|
230
230
|
- Full text search. PostgreSQL has many great features.
|
231
231
|
- Bulk import.
|
232
|
+
- Whitelisting of attributes for models (strong attributes).
|
233
|
+
- Whitelisting of collection names.
|
232
234
|
- Support for files. Maybe as attachments to documents.
|
233
235
|
- Keep the similarities with ActiveRecord API, but it shouldn't depend on Rails or ActiveRecord.
|
234
236
|
- Better performance and less complex code.
|
@@ -34,6 +34,11 @@ module PostJson
|
|
34
34
|
settings
|
35
35
|
end
|
36
36
|
|
37
|
+
def destroy!
|
38
|
+
settings.destroy if persisted?
|
39
|
+
reload_settings!
|
40
|
+
end
|
41
|
+
|
37
42
|
def read_settings_attribute(attribute_name)
|
38
43
|
attribute_name = attribute_name.to_s
|
39
44
|
settings[attribute_name]
|
@@ -114,6 +119,20 @@ module PostJson
|
|
114
119
|
def create_dynamic_index_milliseconds_threshold=(millisecs)
|
115
120
|
write_settings_attribute('create_dynamic_index_milliseconds_threshold', millisecs)
|
116
121
|
end
|
122
|
+
|
123
|
+
def method_missing(method_symbol, *args, &block)
|
124
|
+
method = method_symbol.to_s
|
125
|
+
if method.start_with?("meta_") && method.end_with?("=") && args.length == 1
|
126
|
+
attribute_name = method[5..-2]
|
127
|
+
self.meta = self.meta.merge(attribute_name => args[0])
|
128
|
+
args[0]
|
129
|
+
elsif method.start_with?("meta_") && args.length == 0
|
130
|
+
attribute_name = method[5..-1]
|
131
|
+
self.meta[attribute_name]
|
132
|
+
else
|
133
|
+
super
|
134
|
+
end
|
135
|
+
end
|
117
136
|
end
|
118
137
|
end
|
119
138
|
end
|
data/lib/post_json/version.rb
CHANGED
@@ -1,27 +1,54 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "Collection", :
|
4
|
-
|
5
|
-
|
3
|
+
describe "Collection", :focus do
|
4
|
+
context "meta" do
|
5
|
+
let(:model) { PostJson::Collection["People"] }
|
6
|
+
subject { model }
|
7
|
+
its(:meta) { should == {} }
|
8
|
+
its(:meta_some_attr) { should be_nil }
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
context "attribute set" do
|
11
|
+
before do
|
12
|
+
model.meta_some_attr = 123
|
13
|
+
end
|
14
|
+
its(:meta) { should == {"some_attr" => 123} }
|
15
|
+
its(:meta_some_attr) { should == 123 }
|
11
16
|
|
12
|
-
|
13
|
-
|
17
|
+
context "to nil" do
|
18
|
+
before do
|
19
|
+
model.meta_some_attr = nil
|
20
|
+
end
|
21
|
+
its(:meta) { should == {"some_attr" => nil} }
|
22
|
+
its(:meta_some_attr) { should be_nil }
|
23
|
+
end
|
24
|
+
end
|
14
25
|
end
|
15
26
|
|
16
|
-
|
27
|
+
context "new / persisted" do
|
28
|
+
let(:model) { PostJson::Collection["People"] }
|
29
|
+
subject { model }
|
30
|
+
|
31
|
+
its(:new?) { should be_true }
|
32
|
+
its(:persisted?) { should be_false }
|
33
|
+
|
34
|
+
context "saved" do
|
35
|
+
before do
|
36
|
+
model.settings.save
|
37
|
+
end
|
38
|
+
|
39
|
+
its(:new?) { should be_false }
|
40
|
+
its(:persisted?) { should be_true }
|
17
41
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
42
|
+
context "and destroyed" do
|
43
|
+
before do
|
44
|
+
model.destroy!
|
45
|
+
end
|
46
|
+
|
47
|
+
its(:new?) { should be_true }
|
48
|
+
its(:persisted?) { should be_false }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
25
52
|
end
|
26
53
|
|
27
54
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: post_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Madsen and Martin Thoegersen
|
@@ -80,8 +80,8 @@ dependencies:
|
|
80
80
|
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.0'
|
83
|
-
description:
|
84
|
-
|
83
|
+
description: Fast and flexible Document database by combining features of PostgreSQL
|
84
|
+
with PLV8 and Ruby
|
85
85
|
email:
|
86
86
|
- hello@webnuts.com
|
87
87
|
executables: []
|
@@ -180,5 +180,5 @@ rubyforge_project:
|
|
180
180
|
rubygems_version: 2.1.9
|
181
181
|
signing_key:
|
182
182
|
specification_version: 4
|
183
|
-
summary:
|
183
|
+
summary: PostgreSQL as Document database
|
184
184
|
test_files: []
|