activemodel 4.2.0.beta3 → 4.2.0.beta4

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: 67747155793b73842378cff3bd858c2fb1f50dc1
4
- data.tar.gz: 5582dc1f505f87638a7ec167b4127e20d1e5d719
3
+ metadata.gz: 63a849fdad11a802d8d4fa7c6379f15b85708106
4
+ data.tar.gz: e45928f8b4e67459a0f17bb3abf0aff59d6dc0b0
5
5
  SHA512:
6
- metadata.gz: 6433aa21ddba1cc3cb275fe1093077fe537bb5432151cd8f2e799a417b6d7d8b03f59097f80faa92e7371c748d3c3eff98ec09c4a39654e335a8ca611a495961
7
- data.tar.gz: 2ad634ddaccb1784be802690eac4e45dbad54e144ac3fdc6d5a580eb0438fc4a3ee80bcdb926d65b86b2e3151d64cde62d0667f72a6c58d86da97d33a0a70240
6
+ metadata.gz: cf2e01c6adda8e1a87e87bef60f587a4331e17c88134116f013e7a29e9e8c370f0f13f48d5ab50c3235d5f1bb079313b76a7eec2003cde01291afe7eccc28a5b
7
+ data.tar.gz: be8fa855c0d574ec213a7975e991e2bbd4689a32251b60f6690e0a85fbcea2418d6da712734548e488aea31dd643c63fbcd6844b0e03273283972b938a614551
@@ -97,6 +97,9 @@ module ActiveModel
97
97
  # # obj is the MyModel instance that the callback is being called on
98
98
  # end
99
99
  # end
100
+ #
101
+ # NOTE: +method_name+ passed to `define_model_callbacks` must not end with
102
+ # `!`, `?` or `=`.
100
103
  def define_model_callbacks(*callbacks)
101
104
  options = callbacks.extract_options!
102
105
  options = {
@@ -1,5 +1,6 @@
1
1
  require 'active_support/hash_with_indifferent_access'
2
2
  require 'active_support/core_ext/object/duplicable'
3
+ require 'active_support/core_ext/string/filters'
3
4
 
4
5
  module ActiveModel
5
6
  # == Active \Model \Dirty
@@ -200,7 +201,11 @@ module ActiveModel
200
201
  end
201
202
 
202
203
  def reset_changes
203
- ActiveSupport::Deprecation.warn "#reset_changes is deprecated and will be removed on Rails 5. Please use #clear_changes_information instead."
204
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
205
+ `#reset_changes` is deprecated and will be removed on Rails 5.
206
+ Please use `#clear_changes_information` instead.
207
+ MSG
208
+
204
209
  clear_changes_information
205
210
  end
206
211
 
@@ -224,7 +229,10 @@ module ActiveModel
224
229
 
225
230
  # Handle <tt>reset_*!</tt> for +method_missing+.
226
231
  def reset_attribute!(attr)
227
- ActiveSupport::Deprecation.warn "#reset_#{attr}! is deprecated and will be removed on Rails 5. Please use #restore_#{attr}! instead."
232
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
233
+ `#reset_#{attr}!` is deprecated and will be removed on Rails 5.
234
+ Please use `#restore_#{attr}!` instead.
235
+ MSG
228
236
 
229
237
  restore_attribute!(attr)
230
238
  end
@@ -98,6 +98,8 @@ module ActiveModel
98
98
  end
99
99
  # aliases include?
100
100
  alias :has_key? :include?
101
+ # aliases include?
102
+ alias :key? :include?
101
103
 
102
104
  # Get messages for +key+.
103
105
  #
@@ -8,7 +8,7 @@ module ActiveModel
8
8
  MAJOR = 4
9
9
  MINOR = 2
10
10
  TINY = 0
11
- PRE = "beta3"
11
+ PRE = "beta4"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -68,8 +68,9 @@ module ActiveModel
68
68
  #
69
69
  # Options:
70
70
  # * <tt>:on</tt> - Specifies the contexts where this validation is active.
71
- # You can pass a symbol or an array of symbols.
72
- # (e.g. <tt>on: :create</tt> or <tt>on: :custom_validation_context</tt> or
71
+ # Runs in all validation contexts by default (nil). You can pass a symbol
72
+ # or an array of symbols. (e.g. <tt>on: :create</tt> or
73
+ # <tt>on: :custom_validation_context</tt> or
73
74
  # <tt>on: [:create, :custom_validation_context]</tt>)
74
75
  # * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+.
75
76
  # * <tt>:allow_blank</tt> - Skip validation if attribute is blank.
@@ -130,8 +131,9 @@ module ActiveModel
130
131
  #
131
132
  # Options:
132
133
  # * <tt>:on</tt> - Specifies the contexts where this validation is active.
133
- # You can pass a symbol or an array of symbols.
134
- # (e.g. <tt>on: :create</tt> or <tt>on: :custom_validation_context</tt> or
134
+ # Runs in all validation contexts by default (nil). You can pass a symbol
135
+ # or an array of symbols. (e.g. <tt>on: :create</tt> or
136
+ # <tt>on: :custom_validation_context</tt> or
135
137
  # <tt>on: [:create, :custom_validation_context]</tt>)
136
138
  # * <tt>:if</tt> - Specifies a method, proc or string to call to determine
137
139
  # if the validation should occur (e.g. <tt>if: :allow_validation</tt>,
@@ -156,7 +158,7 @@ module ActiveModel
156
158
  if options.key?(:on)
157
159
  options = options.dup
158
160
  options[:if] = Array(options[:if])
159
- options[:if].unshift lambda { |o|
161
+ options[:if].unshift ->(o) {
160
162
  Array(options[:on]).include?(o.validation_context)
161
163
  }
162
164
  end
@@ -390,7 +392,7 @@ module ActiveModel
390
392
  protected
391
393
 
392
394
  def run_validations! #:nodoc:
393
- run_callbacks :validate
395
+ _run_validate_callbacks
394
396
  errors.empty?
395
397
  end
396
398
  end
@@ -58,7 +58,7 @@ module ActiveModel
58
58
  if options.is_a?(Hash) && options[:on]
59
59
  options[:if] = Array(options[:if])
60
60
  options[:on] = Array(options[:on])
61
- options[:if].unshift lambda { |o|
61
+ options[:if].unshift ->(o) {
62
62
  options[:on].include? o.validation_context
63
63
  }
64
64
  end
@@ -98,7 +98,9 @@ module ActiveModel
98
98
  options[:if] = Array(options[:if])
99
99
  if options[:on]
100
100
  options[:on] = Array(options[:on])
101
- options[:if].unshift("#{options[:on]}.include? self.validation_context")
101
+ options[:if].unshift ->(o) {
102
+ options[:on].include? o.validation_context
103
+ }
102
104
  end
103
105
  set_callback(:validation, :after, *(args << options), &block)
104
106
  end
@@ -108,7 +110,7 @@ module ActiveModel
108
110
 
109
111
  # Overwrite run validations to include callbacks.
110
112
  def run_validations! #:nodoc:
111
- run_callbacks(:validation) { super }
113
+ _run_validation_callbacks { super }
112
114
  end
113
115
  end
114
116
  end
@@ -67,7 +67,7 @@ module ActiveModel
67
67
  end
68
68
 
69
69
  def parse_raw_value_as_an_integer(raw_value)
70
- raw_value.to_i if raw_value.to_s =~ /\A[+-]?\d+\Z/
70
+ raw_value.to_i if raw_value.to_s =~ /\A[+-]?\d+\z/
71
71
  end
72
72
 
73
73
  def filtered_options(value)
@@ -71,9 +71,11 @@ module ActiveModel
71
71
  #
72
72
  # There is also a list of options that could be used along with validators:
73
73
  #
74
- # * <tt>:on</tt> - Specifies when this validation is active. Runs in all
75
- # validation contexts by default (+nil+), other options are <tt>:create</tt>
76
- # and <tt>:update</tt>.
74
+ # * <tt>:on</tt> - Specifies the contexts where this validation is active.
75
+ # Runs in all validation contexts by default (nil). You can pass a symbol
76
+ # or an array of symbols. (e.g. <tt>on: :create</tt> or
77
+ # <tt>on: :custom_validation_context</tt> or
78
+ # <tt>on: [:create, :custom_validation_context]</tt>)
77
79
  # * <tt>:if</tt> - Specifies a method, proc or string to call to determine
78
80
  # if the validation should occur (e.g. <tt>if: :allow_validation</tt>,
79
81
  # or <tt>if: Proc.new { |user| user.signup_step > 2 }</tt>). The method,
@@ -52,8 +52,11 @@ module ActiveModel
52
52
  # end
53
53
  #
54
54
  # Configuration options:
55
- # * <tt>:on</tt> - Specifies when this validation is active
56
- # (<tt>:create</tt> or <tt>:update</tt>).
55
+ # * <tt>:on</tt> - Specifies the contexts where this validation is active.
56
+ # Runs in all validation contexts by default (nil). You can pass a symbol
57
+ # or an array of symbols. (e.g. <tt>on: :create</tt> or
58
+ # <tt>on: :custom_validation_context</tt> or
59
+ # <tt>on: [:create, :custom_validation_context]</tt>)
57
60
  # * <tt>:if</tt> - Specifies a method, proc or string to call to determine
58
61
  # if the validation should occur (e.g. <tt>if: :allow_validation</tt>,
59
62
  # or <tt>if: Proc.new { |user| user.signup_step > 2 }</tt>).
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.beta3
4
+ version: 4.2.0.beta4
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-10-29 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,26 +16,26 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.0.beta3
19
+ version: 4.2.0.beta4
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.beta3
26
+ version: 4.2.0.beta4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.1'
41
41
  description: A toolkit for building modeling frameworks like Active Record. Rich support
@@ -94,17 +94,17 @@ require_paths:
94
94
  - lib
95
95
  required_ruby_version: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - ">="
97
+ - - '>='
98
98
  - !ruby/object:Gem::Version
99
99
  version: 1.9.3
100
100
  required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ">"
102
+ - - '>'
103
103
  - !ruby/object:Gem::Version
104
104
  version: 1.3.1
105
105
  requirements: []
106
106
  rubyforge_project:
107
- rubygems_version: 2.2.2
107
+ rubygems_version: 2.2.1
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: A toolkit for building modeling frameworks (part of Rails).