activemodel 5.2.0 → 5.2.1.rc1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62f5923904cebf46662f51db93665e6ba4cca4147281b55ff7010de3f355de85
4
- data.tar.gz: cff4d4f0f1df4fb16fb92876ea267c349bcee44486151936aa2af56e3b8c2a62
3
+ metadata.gz: 8b824abe75d547112f666ea244b01d9efdfe385b4307d01abc02029d417ce127
4
+ data.tar.gz: d091044bf9888873e9eafb7c872a921b3a8b0420fb29146c43f6fe54c0b667e6
5
5
  SHA512:
6
- metadata.gz: defb13fa341109b9cdb821e86e8846c1091b7c11c7b95ff223b7e7511bd4c0b585f96a66699fe5719bbad430ea994b8609b96a1f84be4d526521c336def48a93
7
- data.tar.gz: 5a15688523d7c41152bac1fb2925b1241df1f1391880592d3849168f34fde9bfe6440032873bf20a73fab7118a01c55b913276a903c46959ba9ad7ea5c25c93a
6
+ metadata.gz: 538acb7c8f53bbd99d1d020e77a9696cc9b14970ffb2dc4f2ee07345c5118eb2f71a07c40cae6d640ffbc76577714591c06ad2e3afbcd093a9bbe1e1d8891b4f
7
+ data.tar.gz: 60bc4bb46c72b06361f397aae8c0d0b4d0615e35644ee3036822a79a96711887b1884aac14215128414d40015766639db7ac621b3236c9e62c3d467f50146f5c
@@ -1,3 +1,8 @@
1
+ ## Rails 5.2.1.rc1 (July 30, 2018) ##
2
+
3
+ * No changes.
4
+
5
+
1
6
  ## Rails 5.2.0 (April 09, 2018) ##
2
7
 
3
8
  * Do not lose all multiple `:includes` with options in serialization.
@@ -11,6 +11,10 @@ module ActiveModel
11
11
  @forced_changes = Set.new
12
12
  end
13
13
 
14
+ def changed_attribute_names
15
+ attr_names.select { |attr_name| changed?(attr_name) }
16
+ end
17
+
14
18
  def changed_values
15
19
  attr_names.each_with_object({}.with_indifferent_access) do |attr_name, result|
16
20
  if changed?(attr_name)
@@ -23,7 +27,7 @@ module ActiveModel
23
27
  attr_names.each_with_object({}.with_indifferent_access) do |attr_name, result|
24
28
  change = change_to_attribute(attr_name)
25
29
  if change
26
- result[attr_name] = change
30
+ result.merge!(attr_name => change)
27
31
  end
28
32
  end
29
33
  end
@@ -81,6 +85,10 @@ module ActiveModel
81
85
  class NullMutationTracker # :nodoc:
82
86
  include Singleton
83
87
 
88
+ def changed_attribute_names(*)
89
+ []
90
+ end
91
+
84
92
  def changed_values(*)
85
93
  {}
86
94
  end
@@ -323,7 +323,7 @@ module ActiveModel
323
323
  # person.errors.added? :name, "is too long" # => false
324
324
  def added?(attribute, message = :invalid, options = {})
325
325
  if message.is_a? Symbol
326
- self.details[attribute].map { |e| e[:error] }.include? message
326
+ self.details[attribute.to_sym].map { |e| e[:error] }.include? message
327
327
  else
328
328
  message = message.call if message.respond_to?(:call)
329
329
  message = normalize_message(attribute, message, options)
@@ -9,8 +9,8 @@ module ActiveModel
9
9
  module VERSION
10
10
  MAJOR = 5
11
11
  MINOR = 2
12
- TINY = 0
13
- PRE = nil
12
+ TINY = 1
13
+ PRE = "rc1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -20,6 +20,10 @@ module ActiveModel
20
20
  :boolean
21
21
  end
22
22
 
23
+ def serialize(value) # :nodoc:
24
+ cast(value)
25
+ end
26
+
23
27
  private
24
28
 
25
29
  def cast_value(value)
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_support/core_ext/string/zones"
3
4
  require "active_support/core_ext/time/zones"
4
5
 
5
6
  module ActiveModel
@@ -18,6 +18,8 @@ module ActiveModel
18
18
  case value
19
19
  when ::String
20
20
  value = "2000-01-01 #{value}"
21
+ time_hash = ::Date._parse(value)
22
+ return if time_hash[:hour].nil?
21
23
  when ::Time
22
24
  value = value.change(year: 2000, day: 1, month: 1)
23
25
  end
@@ -90,6 +90,10 @@ module ActiveModel
90
90
  false
91
91
  end
92
92
 
93
+ def force_equality?(_value) # :nodoc:
94
+ false
95
+ end
96
+
93
97
  def map(value) # :nodoc:
94
98
  yield value
95
99
  end
@@ -19,9 +19,11 @@ module ActiveModel
19
19
  end
20
20
 
21
21
  def validate_each(record, attr_name, value)
22
- before_type_cast = :"#{attr_name}_before_type_cast"
22
+ came_from_user = :"#{attr_name}_came_from_user?"
23
23
 
24
- raw_value = record.send(before_type_cast) if record.respond_to?(before_type_cast) && record.send(before_type_cast) != value
24
+ if record.respond_to?(came_from_user) && record.public_send(came_from_user)
25
+ raw_value = record.read_attribute_before_type_cast(attr_name)
26
+ end
25
27
  raw_value ||= value
26
28
 
27
29
  if record_attribute_changed_in_place?(record, attr_name)
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: 5.2.0
4
+ version: 5.2.1.rc1
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: 2018-04-09 00:00:00.000000000 Z
11
+ date: 2018-07-30 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: 5.2.0
19
+ version: 5.2.1.rc1
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: 5.2.0
26
+ version: 5.2.1.rc1
27
27
  description: A toolkit for building modeling frameworks like Active Record. Rich support
28
28
  for attributes, callbacks, validations, serialization, internationalization, and
29
29
  testing.
@@ -100,8 +100,8 @@ homepage: http://rubyonrails.org
100
100
  licenses:
101
101
  - MIT
102
102
  metadata:
103
- source_code_uri: https://github.com/rails/rails/tree/v5.2.0/activemodel
104
- changelog_uri: https://github.com/rails/rails/blob/v5.2.0/activemodel/CHANGELOG.md
103
+ source_code_uri: https://github.com/rails/rails/tree/v5.2.1.rc1/activemodel
104
+ changelog_uri: https://github.com/rails/rails/blob/v5.2.1.rc1/activemodel/CHANGELOG.md
105
105
  post_install_message:
106
106
  rdoc_options: []
107
107
  require_paths:
@@ -113,12 +113,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  version: 2.2.2
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ">="
116
+ - - ">"
117
117
  - !ruby/object:Gem::Version
118
- version: '0'
118
+ version: 1.3.1
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.7.6
121
+ rubygems_version: 2.7.3
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: A toolkit for building modeling frameworks (part of Rails).