mongoid 3.1.0 → 3.1.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.
@@ -3,7 +3,17 @@
3
3
  For instructions on upgrading to newer versions, visit
4
4
  [mongoid.org](http://mongoid.org/en/mongoid/docs/upgrading.html).
5
5
 
6
- ## 3.1.0 (branch: master)
6
+ ## 3.1.1
7
+
8
+ * \#2839 Validations fixed to use the type cast value with the exception
9
+ of the numericality validator. (Lailson Bandeira)
10
+
11
+ * \#2838 `store_in` options now properly merge instead of override.
12
+ (Colin MacKenzie)
13
+
14
+ ### Resolved Issues
15
+
16
+ ## 3.1.0
7
17
 
8
18
  ### New Features
9
19
 
@@ -12,7 +12,6 @@ module Mongoid
12
12
  include Readonly
13
13
 
14
14
  attr_reader :attributes
15
- attr_reader :attributes_before_type_cast
16
15
  alias :raw_attributes :attributes
17
16
 
18
17
  # Determine if an attribute is present.
@@ -30,6 +29,18 @@ module Mongoid
30
29
  !attribute.blank? || attribute == false
31
30
  end
32
31
 
32
+ # Get the attributes that have not been cast.
33
+ #
34
+ # @example Get the attributes before type cast.
35
+ # document.attributes_before_type_cast
36
+ #
37
+ # @return [ Hash ] The uncast attributes.
38
+ #
39
+ # @since 3.1.0
40
+ def attributes_before_type_cast
41
+ @attributes_before_type_cast ||= {}
42
+ end
43
+
33
44
  # Does the document have the provided attribute?
34
45
  #
35
46
  # @example Does the document have the attribute?
@@ -89,7 +89,6 @@ module Mongoid
89
89
  _building do
90
90
  @new_record = true
91
91
  @attributes ||= {}
92
- @attributes_before_type_cast ||= {}
93
92
  options ||= {}
94
93
  apply_pre_processed_defaults
95
94
  process_attributes(attrs, options[:as] || :default, !options[:without_protection]) do
@@ -285,7 +284,6 @@ module Mongoid
285
284
  doc = allocate
286
285
  doc.criteria_instance_id = criteria_instance_id
287
286
  doc.instance_variable_set(:@attributes, attributes)
288
- doc.instance_variable_set(:@attributes_before_type_cast, {})
289
287
  doc.apply_defaults
290
288
  IdentityMap.set(doc) unless _loading_revision?
291
289
  yield(doc) if block_given?
@@ -179,7 +179,8 @@ module Mongoid
179
179
  unless fields.has_key?("_type")
180
180
  field(:_type, default: self.name, type: String)
181
181
  end
182
- subclass.field(:_type, default: subclass.name, type: String)
182
+ subclass_default = subclass.name || ->{ self.class.name }
183
+ subclass.field(:_type, default: subclass_default, type: String)
183
184
  end
184
185
  end
185
186
  end
@@ -293,7 +293,8 @@ module Mongoid
293
293
  def store_in(options)
294
294
  Validators::Storage.validate(self, options)
295
295
  @collection_name, @database_name = nil, nil
296
- self.storage_options = options
296
+ self.storage_options ||= {}
297
+ self.storage_options.merge! options
297
298
  end
298
299
 
299
300
  # Tell the next persistance operation to store in a specific collection,
@@ -62,8 +62,6 @@ module Mongoid
62
62
  relation.do_or_do_not(:in_memory) || relation
63
63
  elsif fields[attribute].try(:localized?)
64
64
  attributes[attribute]
65
- elsif respond_to?("#{attr}_before_type_cast")
66
- send("#{attr}_before_type_cast")
67
65
  else
68
66
  send(attr)
69
67
  end
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Mongoid
3
- VERSION = "3.1.0"
3
+ VERSION = "3.1.1"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
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: 2013-02-13 00:00:00.000000000 Z
12
+ date: 2013-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -375,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
375
375
  version: 1.3.6
376
376
  requirements: []
377
377
  rubyforge_project: mongoid
378
- rubygems_version: 1.8.24
378
+ rubygems_version: 1.8.25
379
379
  signing_key:
380
380
  specification_version: 3
381
381
  summary: Elegant Persistance in Ruby for MongoDB.