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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa932b050d7417a30200065e08bd1f1b7c769107
4
- data.tar.gz: e710e6b680d1996ba891a8ab8939084f3325e80d
3
+ metadata.gz: 24311aa26e3346bf960345d304ce06d55b81dff8
4
+ data.tar.gz: a66129b2cb4b677ea05cfa55a5ff0f606ea711f8
5
5
  SHA512:
6
- metadata.gz: c147cef8a8a9ad828c0a20062a354d43d8ebcaa243cdb24ad3ba5facd2cab7db258300b2ae6df8f741b8bfc825dfec5c6bedd23393b940701186128ea9d64349
7
- data.tar.gz: 2515e810ee5260fad961ac819e9f666ce2e9458e46a5f507581952e8e81c40ed5e73583efc276bc95c7bf5f50d6f18131e17d788549bbdde9244833ba584dbd3
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 = nil)
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
- if @response.code != 200
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.find_one(query, params, opts = nil)
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 = nil)
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
@@ -1,5 +1,5 @@
1
1
 
2
2
 
3
3
  module Proxima
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
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
- type[:from_json].call(value) if type else value
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
- type[:to_json].call(value) if type else value
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.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-17 00:00:00.000000000 Z
11
+ date: 2017-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler