activemodel 5.2.0.beta1 → 5.2.0.beta2

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
  SHA1:
3
- metadata.gz: 9a527b6fc9e7656a84868c763aec48bb368d7bfd
4
- data.tar.gz: 4c6ebab7e83916520a612437380b074e002f37e1
3
+ metadata.gz: f8bb0c3867c3dfe9215c08be8eb1e993ade817b4
4
+ data.tar.gz: 13b15b80b683e29fc4b3b603afd762a90264b8a8
5
5
  SHA512:
6
- metadata.gz: 0671a93f14567ade18a581e3e0c848771e002261eccddcb703aa0b77f9574c1a2d2e091f2f295cafc37ce20e220dc01488b99e14653fb10d4415f4658c5396fb
7
- data.tar.gz: 1385ef9675c0c9fd44b6acd88f55d3a25db8c0a5e42607b5ae12908e883aea9882c2fa42bcee5e50e585f1c46e023629878ef3bc40764ccb473efc32c81aaec4
6
+ metadata.gz: 753ce129d560dc612f06f6e159c7ad2300181f9d28391e50c1697b310c377c76385fe0db72edfcb31961731b568eff6bb4d8a35cb4b988145718d41f538b4c36
7
+ data.tar.gz: ca6bbdaa75becdb24782a026c82fc88d68f15da756914639ff26c31b390496758833f76bdf7d5725be7dc397a9d2bc166ef107624f044e0977b0e1b7465dd4d2
@@ -1,3 +1,8 @@
1
+ ## Rails 5.2.0.beta2 (November 28, 2017) ##
2
+
3
+ * No changes.
4
+
5
+
1
6
  ## Rails 5.2.0.beta1 (November 27, 2017) ##
2
7
 
3
8
  * Execute `ConfirmationValidator` validation when `_confirmation`'s value is `false`.
@@ -5,7 +5,7 @@ require "active_model/attribute_set/yaml_encoder"
5
5
 
6
6
  module ActiveModel
7
7
  class AttributeSet # :nodoc:
8
- delegate :each_value, :fetch, to: :attributes
8
+ delegate :each_value, :fetch, :except, to: :attributes
9
9
 
10
10
  def initialize(attributes)
11
11
  @attributes = attributes
@@ -5,35 +5,30 @@ require "active_model/attribute"
5
5
  module ActiveModel
6
6
  class AttributeSet # :nodoc:
7
7
  class Builder # :nodoc:
8
- attr_reader :types, :always_initialized, :default
8
+ attr_reader :types, :default_attributes
9
9
 
10
- def initialize(types, always_initialized = nil, &default)
10
+ def initialize(types, default_attributes = {})
11
11
  @types = types
12
- @always_initialized = always_initialized
13
- @default = default
12
+ @default_attributes = default_attributes
14
13
  end
15
14
 
16
15
  def build_from_database(values = {}, additional_types = {})
17
- if always_initialized && !values.key?(always_initialized)
18
- values[always_initialized] = nil
19
- end
20
-
21
- attributes = LazyAttributeHash.new(types, values, additional_types, &default)
16
+ attributes = LazyAttributeHash.new(types, values, additional_types, default_attributes)
22
17
  AttributeSet.new(attributes)
23
18
  end
24
19
  end
25
20
  end
26
21
 
27
22
  class LazyAttributeHash # :nodoc:
28
- delegate :transform_values, :each_key, :each_value, :fetch, to: :materialize
23
+ delegate :transform_values, :each_key, :each_value, :fetch, :except, to: :materialize
29
24
 
30
- def initialize(types, values, additional_types, &default)
25
+ def initialize(types, values, additional_types, default_attributes)
31
26
  @types = types
32
27
  @values = values
33
28
  @additional_types = additional_types
34
29
  @materialized = false
35
30
  @delegate_hash = {}
36
- @default = default || proc {}
31
+ @default_attributes = default_attributes
37
32
  end
38
33
 
39
34
  def key?(key)
@@ -94,7 +89,7 @@ module ActiveModel
94
89
 
95
90
  protected
96
91
 
97
- attr_reader :types, :values, :additional_types, :delegate_hash, :default
92
+ attr_reader :types, :values, :additional_types, :delegate_hash, :default_attributes
98
93
 
99
94
  def materialize
100
95
  unless @materialized
@@ -117,7 +112,12 @@ module ActiveModel
117
112
  if value_present
118
113
  delegate_hash[name] = Attribute.from_database(name, value, type)
119
114
  elsif types.key?(name)
120
- delegate_hash[name] = default.call(name) || Attribute.uninitialized(name, type)
115
+ attr = default_attributes[name]
116
+ if attr
117
+ delegate_hash[name] = attr.dup
118
+ else
119
+ delegate_hash[name] = Attribute.uninitialized(name, type)
120
+ end
121
121
  end
122
122
  end
123
123
  end
@@ -10,7 +10,7 @@ module ActiveModel
10
10
  MAJOR = 5
11
11
  MINOR = 2
12
12
  TINY = 0
13
- PRE = "beta1"
13
+ PRE = "beta2"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
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.beta1
4
+ version: 5.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: 2017-11-27 00:00:00.000000000 Z
11
+ date: 2017-11-28 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.beta1
19
+ version: 5.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: 5.2.0.beta1
26
+ version: 5.2.0.beta2
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.beta1/activemodel
104
- changelog_uri: https://github.com/rails/rails/blob/v5.2.0.beta1/activemodel/CHANGELOG.md
103
+ source_code_uri: https://github.com/rails/rails/tree/v5.2.0.beta2/activemodel
104
+ changelog_uri: https://github.com/rails/rails/blob/v5.2.0.beta2/activemodel/CHANGELOG.md
105
105
  post_install_message:
106
106
  rdoc_options: []
107
107
  require_paths: