post_json 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f25ad4b6cb31d0b679bfa6c41d8b5533c3c69a8
4
- data.tar.gz: 25b074ed6292d61272a2b3bb08c021d32ca881af
3
+ metadata.gz: fe619530d2d95e8da438a6ff399d7d2972188114
4
+ data.tar.gz: a65c7296009eef778e19ae160d174ebea791d5da
5
5
  SHA512:
6
- metadata.gz: 9783c9e9b72e4d5f6fadd58718a25c3a13c29a1b6168997f1abbbb7511c21d5891badde842b51b70885b19a077d63d5595acc891a7e486f464eb9bf574d9667f
7
- data.tar.gz: 71267eaa0731c1a4340ec28808fcbcd3961ccddb36b5525170bc3b85727fac0d9d78d22f96ae2133c82758462c6d1ec6af385472b8de03c3c7f53e4eacd3d327
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 performance. Like a threshold of 1 millisecond will be less than the duration of almost all queries.
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
@@ -1,3 +1,3 @@
1
1
  module PostJson
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
@@ -1,27 +1,54 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Collection", :ignore do
4
- let(:collection) { PostJson::Collection }
5
- subject { collection }
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
- context "initialize" do
8
- before do
9
- subject.initialize([{name: "Customers", use_timestamps: false}, {name: "Orders/", use_version_number: false}])
10
- end
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
- it { subject.where(name: "customers").first.use_timestamps.should be_false }
13
- it { subject.where(name: "orders").first.use_version_number.should be_false }
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
- # context "empty database" do
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
- # it { should respond_to(:create).with(2).arguments }
19
- # it { should respond_to(:all_names).with(0).arguments }
20
- # it { should respond_to(:[]).with(1).argument }
21
- # it { should respond_to(:initialize).with(1).argument }
22
- # it { should respond_to(:destroy_all!).with(0).arguments }
23
- # it { should respond_to(:fake_it).with(1).argument }
24
- # end
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.7
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: Great Document Database by combining features of Ruby, ActiveRecord and
84
- PostgreSQL with PLV8
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: Great Document Database
183
+ summary: PostgreSQL as Document database
184
184
  test_files: []