activemodel 5.2.0.beta1 → 5.2.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/active_model/attribute_set.rb +1 -1
- data/lib/active_model/attribute_set/builder.rb +14 -14
- data/lib/active_model/gem_version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8bb0c3867c3dfe9215c08be8eb1e993ade817b4
|
4
|
+
data.tar.gz: 13b15b80b683e29fc4b3b603afd762a90264b8a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 753ce129d560dc612f06f6e159c7ad2300181f9d28391e50c1697b310c377c76385fe0db72edfcb31961731b568eff6bb4d8a35cb4b988145718d41f538b4c36
|
7
|
+
data.tar.gz: ca6bbdaa75becdb24782a026c82fc88d68f15da756914639ff26c31b390496758833f76bdf7d5725be7dc397a9d2bc166ef107624f044e0977b0e1b7465dd4d2
|
data/CHANGELOG.md
CHANGED
@@ -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, :
|
8
|
+
attr_reader :types, :default_attributes
|
9
9
|
|
10
|
-
def initialize(types,
|
10
|
+
def initialize(types, default_attributes = {})
|
11
11
|
@types = types
|
12
|
-
@
|
13
|
-
@default = default
|
12
|
+
@default_attributes = default_attributes
|
14
13
|
end
|
15
14
|
|
16
15
|
def build_from_database(values = {}, additional_types = {})
|
17
|
-
|
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,
|
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
|
-
@
|
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, :
|
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
|
-
|
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
|
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.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-
|
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.
|
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.
|
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.
|
104
|
-
changelog_uri: https://github.com/rails/rails/blob/v5.2.0.
|
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:
|