proxima 1.0.0 → 1.0.1
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/lib/proxima/model.rb +12 -21
- data/lib/proxima/version.rb +1 -1
- data/lib/proxima.rb +10 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24311aa26e3346bf960345d304ce06d55b81dff8
|
4
|
+
data.tar.gz: a66129b2cb4b677ea05cfa55a5ff0f606ea711f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aff9c654c5b106aec74ec6dfa1941e2857b82960081834ce8859b37c9212888d9ee0577f80c22b7d6bfeb1ad017cce6f66346073ae2f0d7d7d07840ec6a4ba7c
|
7
|
+
data.tar.gz: a270bd19fa4b9350326d9783ab91226b5b23953350f947f1aad1c9bb00479d76c75e10016f69b7bbaf8fe67f20534bb34ef980fbdca9e2a7e22c3543a823c511
|
data/lib/proxima/model.rb
CHANGED
@@ -60,38 +60,29 @@ module Proxima
|
|
60
60
|
model
|
61
61
|
end
|
62
62
|
|
63
|
-
def self.find(query = {}, params = {}, opts =
|
64
|
-
|
65
|
-
# NOTE: This is a compatibility fix for 0.2 to 0.3
|
66
|
-
if opts == nil
|
67
|
-
opts = params
|
68
|
-
params = query
|
69
|
-
end
|
70
|
-
|
63
|
+
def self.find(query = {}, params = {}, opts = {})
|
71
64
|
opts[:query] = self.convert_query_or_delta_to_json query
|
72
|
-
@response = self.api.get self.find_path.call(params), opts
|
65
|
+
@response = self.api.get self.find_path.call(params.merge(query)), opts
|
73
66
|
|
74
|
-
|
75
|
-
return []
|
76
|
-
end
|
67
|
+
return [] unless @response.code == 200
|
77
68
|
|
78
69
|
models = self.from_json @response.body
|
79
70
|
models.each { |model| model.new_record = false }
|
80
71
|
end
|
81
72
|
|
82
|
-
def self.
|
73
|
+
def self.count_and_find(query = {}, params = {}, opts = {})
|
74
|
+
items = self.find query, params, opts
|
75
|
+
total_count = self.response.headers[:x_total_count].to_i || 0
|
76
|
+
|
77
|
+
Struct.new(:total_count, :items).new(total_count, items)
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.find_one(query = {}, params = {}, opts = {})
|
83
81
|
query['$limit'] = 1
|
84
82
|
self.find(query, params, opts)[0]
|
85
83
|
end
|
86
84
|
|
87
|
-
def self.count(query = {}, params = {}, opts =
|
88
|
-
|
89
|
-
# NOTE: This is a compatibility fix for 0.2 to 0.3
|
90
|
-
if opts == nil
|
91
|
-
opts = params
|
92
|
-
params = query
|
93
|
-
end
|
94
|
-
|
85
|
+
def self.count(query = {}, params = {}, opts = {})
|
95
86
|
query['$limit'] = 0
|
96
87
|
opts[:query] = self.convert_query_or_delta_to_json query
|
97
88
|
@response = self.api.get self.find_path.call(params), opts
|
data/lib/proxima/version.rb
CHANGED
data/lib/proxima.rb
CHANGED
@@ -63,11 +63,19 @@ module Proxima
|
|
63
63
|
|
64
64
|
def self.type_from_json(klass, value)
|
65
65
|
type = @types.find { |t| t[:klass] == klass }
|
66
|
-
|
66
|
+
if type
|
67
|
+
type[:from_json].call(value)
|
68
|
+
else
|
69
|
+
value
|
70
|
+
end
|
67
71
|
end
|
68
72
|
|
69
73
|
def self.type_to_json(klass, value)
|
70
74
|
type = @types.find { |t| t[:klass] == klass }
|
71
|
-
|
75
|
+
if type
|
76
|
+
type[:to_json].call(value)
|
77
|
+
else
|
78
|
+
value
|
79
|
+
end
|
72
80
|
end
|
73
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxima
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Hurst
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|