mongo_light 0.1.2 → 0.1.3

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.
@@ -53,45 +53,44 @@ module MongoLight
53
53
  c.find(map(selector)).count
54
54
  end
55
55
  end
56
- module InstanceMethods
57
- def initialize(attributes = {})
58
- attributes = {} unless attributes
59
- @attributes = {:_id => (attributes['_id'] || attributes[:_id] || Id.new)}
60
- attributes.each do |k,v|
61
- if self.class.map_include?(k)
62
- @attributes[k] = v
63
- elsif k != :_id && k != '_id'
64
- send("#{k}=", v)
65
- end
56
+
57
+ def initialize(attributes = {})
58
+ attributes = {} unless attributes
59
+ @attributes = {:_id => (attributes['_id'] || attributes[:_id] || Id.new)}
60
+ attributes.each do |k,v|
61
+ if self.class.map_include?(k)
62
+ @attributes[k] = v
63
+ elsif k != :_id && k != '_id'
64
+ send("#{k}=", v)
66
65
  end
67
66
  end
68
- def eql?(other)
69
- other.is_a?(self.class) && id == other.id
70
- end
71
- alias :== :eql?
72
- def hash
73
- id.hash
74
- end
75
- def id
76
- @attributes[:_id] || @attributes['_id']
77
- end
78
- def id=(value)
79
- @attributes[:_id] = value
80
- end
81
- def ==(other)
82
- other.class == self.class && id == other.id
83
- end
84
- def collection
85
- self.class.collection
86
- end
87
- def save(options = nil)
88
- opts = !options || options.include?(:safe) ? options : {:safe => options}
89
- opts[:safe].delete(:w) if MongoLight.configuration.skip_replica_concern && opts && opts.include?(:safe) && opts[:safe].is_a?(Hash)
90
- collection.save(self.class.map(@attributes), opts || {})
91
- end
92
- def save!(options = {})
93
- save({:safe => true}.merge(options))
94
- end
67
+ end
68
+ def eql?(other)
69
+ other.is_a?(self.class) && id == other.id
70
+ end
71
+ alias :== :eql?
72
+ def hash
73
+ id.hash
74
+ end
75
+ def id
76
+ @attributes[:_id] || @attributes['_id']
77
+ end
78
+ def id=(value)
79
+ @attributes[:_id] = value
80
+ end
81
+ def ==(other)
82
+ other.class == self.class && id == other.id
83
+ end
84
+ def collection
85
+ self.class.collection
86
+ end
87
+ def save(options = nil)
88
+ opts = !options || options.include?(:safe) ? options : {:safe => options}
89
+ opts[:safe].delete(:w) if MongoLight.configuration.skip_replica_concern && opts && opts.include?(:safe) && opts[:safe].is_a?(Hash)
90
+ collection.save(self.class.map(@attributes), opts || {})
91
+ end
92
+ def save!(options = {})
93
+ save({:safe => true}.merge(options))
95
94
  end
96
95
  end
97
96
  end
@@ -68,23 +68,21 @@ module MongoLight
68
68
  @map.include?(key)
69
69
  end
70
70
  end
71
- module InstanceMethods
72
- def initialize(attributes = {})
73
- @attributes = {}
74
- attributes.each do |k,v|
75
- if self.class.map_include?(k)
76
- @attributes[k] = v
77
- else
78
- send("#{k}=", v)
79
- end
71
+ def initialize(attributes = {})
72
+ @attributes = {}
73
+ attributes.each do |k,v|
74
+ if self.class.map_include?(k)
75
+ @attributes[k] = v
76
+ else
77
+ send("#{k}=", v)
80
78
  end
81
79
  end
82
- def [](name)
83
- @attributes[name]
84
- end
85
- def attributes
86
- @attributes
87
- end
80
+ end
81
+ def [](name)
82
+ @attributes[name]
83
+ end
84
+ def attributes
85
+ @attributes
88
86
  end
89
87
  end
90
88
  end
@@ -1,3 +1,3 @@
1
1
  module MongoLight
2
- Version = '0.1.2'
2
+ Version = '0.1.3'
3
3
  end
data/readme.markdown CHANGED
@@ -15,7 +15,7 @@ Configure MongoLight via `MongoLight.configure`:
15
15
 
16
16
  This'll automatically handle Passenger forking issues (if Passenger is running).
17
17
 
18
- ## replica cocnern and testing ##
18
+ ## replica concern and testing ##
19
19
  For safe writes, I like to use `w:majority`. However, MongoDB will raise an exception if you use this while not using replica sets. This can make testing code more of a pain than necessary. If you configure MongoLight with `config.skip_replica_concern = true`, then `:w => X` or `:w => :majority` will automatically be stripped when calling `save(:w => majority)` or `save!(:w => 3)`. (For example, you could do `config.skip_replica_concern = Rails.env.test?`)
20
20
 
21
21
  ## Documents ##
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_light
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-30 00:00:00.000000000 Z
12
+ date: 2012-03-24 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: