activemodel 4.2.0.beta1 → 4.2.0.beta2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activemodel might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0ba324f942bc460e8ac9ddf05db07b267fddba7
4
- data.tar.gz: dcc2d9b2e52755dc827b2880015524238d1d7b69
3
+ metadata.gz: 6aed706498bb76758fef9222954e4c3d8b3955fc
4
+ data.tar.gz: 69e08b91b2132101fb48aedc77c44a4fcd02653a
5
5
  SHA512:
6
- metadata.gz: e3c419a3cbe8624a7a38c212c8cb87e6931cc0b8319090c0fbe7029cc4650f875d4faba74dbe009d8940e6fd7a7fd8e3bb4d4d8c2059fb91663609f08f684931
7
- data.tar.gz: 2fb78243d20a5ba5d167b132946d782629ea932308ff1ba970bf177ee0e79894b62b13985a112abd43a0cf3357071510090a6bbea38d3ce82eb2b0774fbec4ed
6
+ metadata.gz: 2e4005029000eeb7378c1260820a55ef936236cc0aec561b1b57d64c327c82c501c7f83be687cfd530cdc5e2d7c19f61af33930192d012be77abaefd17b6b4c0
7
+ data.tar.gz: 828f6ddc8fd5645e568405897be9356c1c5edf69d86c8394bb40b6885e479a39f9396facaffbea25547916b69b86e5f850a8633fa2c2d5a946339ff439e6501b
data/CHANGELOG.md CHANGED
@@ -12,18 +12,21 @@
12
12
 
13
13
  * Deprecate `reset_#{attribute}` in favor of `restore_#{attribute}`.
14
14
 
15
- These methods may cause confusion with the `reset_changes` that behaves differently
16
- of them.
15
+ These methods may cause confusion with the `reset_changes`, which has
16
+ different behaviour.
17
+
18
+ *Rafael Mendonça França*
17
19
 
18
20
  * Deprecate `ActiveModel::Dirty#reset_changes` in favor of `#clear_changes_information`.
19
21
 
20
- This method name is causing confusion with the `reset_#{attribute}`
21
- methods. While `reset_name` set the value of the name attribute for the
22
- previous value `reset_changes` only discard the changes and previous
23
- changes.
22
+ Method's name is causing confusion with the `reset_#{attribute}` methods.
23
+ While `reset_name` sets the value of the name attribute to previous value
24
+ `reset_changes` only discards the changes.
25
+
26
+ *Rafael Mendonça França*
24
27
 
25
- * Added `restore_attributes` method to `ActiveModel::Dirty` API to restore all the
26
- changed values to the previous data.
28
+ * Added `restore_attributes` method to `ActiveModel::Dirty` API which restores
29
+ the value of changed attributes to previous value.
27
30
 
28
31
  *Igor G.*
29
32
 
@@ -251,11 +251,9 @@ module ActiveModel
251
251
  # person.errors.to_hash(true) # => {:name=>["name cannot be nil"]}
252
252
  def to_hash(full_messages = false)
253
253
  if full_messages
254
- messages = {}
255
- self.messages.each do |attribute, array|
254
+ self.messages.each_with_object({}) do |(attribute, array), messages|
256
255
  messages[attribute] = array.map { |message| full_message(attribute, message) }
257
256
  end
258
- messages
259
257
  else
260
258
  self.messages.dup
261
259
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveModel
2
- # Returns the version of the currently loaded ActiveModel as a <tt>Gem::Version</tt>
2
+ # Returns the version of the currently loaded Active Model as a <tt>Gem::Version</tt>
3
3
  def self.gem_version
4
4
  Gem::Version.new VERSION::STRING
5
5
  end
@@ -8,7 +8,7 @@ module ActiveModel
8
8
  MAJOR = 4
9
9
  MINOR = 2
10
10
  TINY = 0
11
- PRE = "beta1"
11
+ PRE = "beta2"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -56,13 +56,13 @@ module ActiveModel
56
56
  # refer to the specific modules included in <tt>ActiveModel::Model</tt>
57
57
  # (see below).
58
58
  module Model
59
- def self.included(base) #:nodoc:
60
- base.class_eval do
61
- extend ActiveModel::Naming
62
- extend ActiveModel::Translation
63
- include ActiveModel::Validations
64
- include ActiveModel::Conversion
65
- end
59
+ extend ActiveSupport::Concern
60
+ include ActiveModel::Validations
61
+ include ActiveModel::Conversion
62
+
63
+ included do
64
+ extend ActiveModel::Naming
65
+ extend ActiveModel::Translation
66
66
  end
67
67
 
68
68
  # Initializes a new model with the given +params+.
@@ -75,7 +75,7 @@ module ActiveModel
75
75
  end
76
76
 
77
77
  validates_length_of :password, maximum: ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED
78
- validates_confirmation_of :password, if: ->{ password.present? }
78
+ validates_confirmation_of :password, allow_blank: true
79
79
  end
80
80
 
81
81
  # This code is necessary as long as the protected_attributes gem is supported.
@@ -86,6 +86,8 @@ module ActiveModel
86
86
  validates_with BlockValidator, _merge_attributes(attr_names), &block
87
87
  end
88
88
 
89
+ VALID_OPTIONS_FOR_VALIDATE = [:on, :if, :unless].freeze
90
+
89
91
  # Adds a validation method or block to the class. This is useful when
90
92
  # overriding the +validate+ instance method becomes too unwieldy and
91
93
  # you're looking for more descriptive declaration of your validations.
@@ -144,7 +146,11 @@ module ActiveModel
144
146
  options = args.extract_options!
145
147
 
146
148
  if args.all? { |arg| arg.is_a?(Symbol) }
147
- options.assert_valid_keys([:on, :if, :unless])
149
+ options.each_key do |k|
150
+ unless VALID_OPTIONS_FOR_VALIDATE.include?(k)
151
+ raise ArgumentError.new("Unknown key: #{k.inspect}. Valid keys are: #{VALID_OPTIONS_FOR_VALIDATE.map(&:inspect).join(', ')}. Perhaps you meant to call `validates` instead of `validate`?")
152
+ end
153
+ end
148
154
  end
149
155
 
150
156
  if options.key?(:on)
@@ -54,7 +54,7 @@ module ActiveModel
54
54
  #
55
55
  # Configuration options:
56
56
  # * <tt>:message</tt> - A custom error message (default is: "doesn't match
57
- # confirmation").
57
+ # <tt>%{translated_attribute_name}</tt>").
58
58
  #
59
59
  # There is also a list of default options supported by every validator:
60
60
  # +:if+, +:unless+, +:on+, +:allow_nil+, +:allow_blank+, and +:strict+.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemodel
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0.beta1
4
+ version: 4.2.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-20 00:00:00.000000000 Z
11
+ date: 2014-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.0.beta1
19
+ version: 4.2.0.beta2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.0.beta1
26
+ version: 4.2.0.beta2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  requirement: !ruby/object:Gem::Requirement