kongo 1.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.
Files changed (4) hide show
  1. data/README.md +4 -3
  2. data/lib/kongo.rb +31 -4
  3. data/lib/kongo/version.rb +1 -1
  4. metadata +1 -1
data/README.md CHANGED
@@ -81,7 +81,7 @@ class User < Model
81
81
  Account::find_by_id(self['earnings_account'])
82
82
  end
83
83
  def spend
84
- Account::find_by_id(sefl['spend_account'])
84
+ Account::find_by_id(self['spend_account'])
85
85
  end
86
86
  end
87
87
  ```
@@ -125,7 +125,8 @@ Instead, if we have the possibility of abstracting this into a library, we might
125
125
  module Finance
126
126
 
127
127
  # other finance functionality that does not belong directly to a
128
- # model, eg something like inance::convert_currency
128
+ # model, eg. something like `Finance::convert_currency`
129
+
129
130
  # our finance extensions to the models:
130
131
 
131
132
  module Extensions
@@ -134,7 +135,7 @@ module Finance
134
135
  Account::find_by_id(self['earnings_account'])
135
136
  end
136
137
  def spend
137
- Account::find_by_id(sefl['spend_account'])
138
+ Account::find_by_id(self['spend_account'])
138
139
  end
139
140
  end
140
141
  Kongo::Model.add_extension(:users, User)
@@ -106,7 +106,7 @@ module Kongo
106
106
 
107
107
  # Inspecting a Mongo Model attempts to only show *useful* information,
108
108
  # such as what its extensions are as well as certain ivars.
109
- #
109
+ #
110
110
  def inspect
111
111
  proxy = Object.new
112
112
  @visible_ivars.each do |ivar|
@@ -169,9 +169,9 @@ module Kongo
169
169
  def each
170
170
  @cursor.each { |e| yield Model.new(e, @coll) }
171
171
  end
172
-
172
+
173
173
  # `to_enum` returns an Enumerator which yields the results of the cursor.
174
- #
174
+ #
175
175
  def to_enum
176
176
  Enumerator.new do |yielder|
177
177
  while @cursor.has_next?
@@ -229,6 +229,33 @@ module Kongo
229
229
  delta('$set', k => v)
230
230
  end
231
231
 
232
+ # Default comparison is via the string version of the id.
233
+ #
234
+ # @example Compare two models.
235
+ # person <=> other_person
236
+ #
237
+ # @param [ Kongo::Model ] other The document to compare with.
238
+ #
239
+ # @return [ Integer ] -1, 0, 1.
240
+ #
241
+ def <=>(other)
242
+ self['_id'].to_s <=> other['_id'].to_s
243
+ end
244
+
245
+ # Performs equality checking on the document ids.
246
+ #
247
+ # @example Compare for equality.
248
+ # model == other
249
+ #
250
+ # @param [ Kongo::Model, Object ] other The other object to compare with.
251
+ #
252
+ # @return [ true, false ] True if the ids are equal, false if not.
253
+ #
254
+ def ==(other)
255
+ self.class == other.class &&
256
+ self['_id'] == other['_id']
257
+ end
258
+
232
259
  # Add a delta
233
260
  #
234
261
  # delta '$inc',
@@ -313,7 +340,7 @@ module Kongo
313
340
 
314
341
  # Inspecting a Mongo Model attempts to only show *useful* information,
315
342
  # such as what its extensions are as well as certain ivars.
316
- #
343
+ #
317
344
  def inspect
318
345
  proxy = Object.new
319
346
  @visible_ivars.each do |ivar|
@@ -1,3 +1,3 @@
1
1
  module Kongo
2
- VERSION = '1.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kongo
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: