active_data 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +0 -5
- data/.travis.yml +11 -7
- data/Appraisals +1 -1
- data/CHANGELOG.md +8 -0
- data/active_data.gemspec +1 -1
- data/gemfiles/rails.5.2.gemfile +14 -0
- data/lib/active_data/config.rb +1 -1
- data/lib/active_data/model/associations/reflections/embeds_any.rb +1 -1
- data/lib/active_data/model/dirty.rb +26 -21
- data/lib/active_data/version.rb +1 -1
- data/lib/active_data.rb +2 -0
- data/spec/lib/active_data/model/associations/validations_spec.rb +6 -6
- data/spec/lib/active_data/model/representation_spec.rb +1 -1
- data/spec/lib/active_data/model/validations/associated_spec.rb +2 -2
- data/spec/lib/active_data/model/validations/nested_spec.rb +4 -4
- metadata +8 -8
- data/.rvmrc +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7a72a84858d1c5737ed98029682614052de1281e89d617d934a5ab7e16cd93c
|
4
|
+
data.tar.gz: ca64b3895dd8bbdd4503e8a8425aef4c210e0fb33f15f456bfe69d25fe741776
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18452047bf27f1a2ea4b2428ebc0e887bce1fb03bbed3dc44a0e2867ad761dca984a828796cd4691b9c6a5240f432cfe4f6c79ff20197be044cd30971db84a41
|
7
|
+
data.tar.gz: 9f11d63a14102cee31677b9a97bdda8ff90f734ca3d18d3473ee0fee9da2ae8a61c08e240e4697d4eb86d55f5b56b79412438eeb92fd7f8197098510f2969882
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
2
|
|
3
|
+
AllCops:
|
4
|
+
DisplayCopNames: true
|
5
|
+
TargetRubyVersion: 2.2.10
|
6
|
+
|
3
7
|
Lint/AmbiguousBlockAssociation:
|
4
8
|
Enabled: false
|
5
9
|
|
@@ -54,3 +58,6 @@ Style/AndOr:
|
|
54
58
|
|
55
59
|
Style/DoubleNegation:
|
56
60
|
Enabled: false
|
61
|
+
|
62
|
+
Style/FrozenStringLiteralComment:
|
63
|
+
Enabled: false
|
data/.rubocop_todo.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
sudo: false
|
2
2
|
|
3
3
|
rvm:
|
4
|
-
- 2.2.
|
5
|
-
- 2.3.
|
4
|
+
- 2.2.10
|
5
|
+
- 2.3.7
|
6
|
+
- 2.4.4
|
6
7
|
- rbx
|
7
8
|
|
8
9
|
gemfile:
|
@@ -11,15 +12,18 @@ gemfile:
|
|
11
12
|
- gemfiles/rails.4.2.gemfile
|
12
13
|
- gemfiles/rails.5.0.gemfile
|
13
14
|
- gemfiles/rails.5.1.gemfile
|
15
|
+
- gemfiles/rails.5.2.gemfile
|
14
16
|
|
15
17
|
matrix:
|
16
18
|
allow_failures:
|
17
19
|
- rvm: rbx
|
18
|
-
|
19
|
-
- rvm: 2.4.
|
20
|
-
gemfile: gemfiles/rails.
|
21
|
-
- rvm: 2.4.
|
22
|
-
gemfile: gemfiles/rails.
|
20
|
+
exclude:
|
21
|
+
- rvm: 2.4.4
|
22
|
+
gemfile: gemfiles/rails.4.0.gemfile
|
23
|
+
- rvm: 2.4.4
|
24
|
+
gemfile: gemfiles/rails.4.1.gemfile
|
25
|
+
- rvm: 2.4.4
|
26
|
+
gemfile: gemfiles/rails.4.2.gemfile
|
23
27
|
|
24
28
|
before_install:
|
25
29
|
- gem update --system --no-doc
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
data/active_data.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_development_dependency 'rake'
|
21
21
|
gem.add_development_dependency 'rspec'
|
22
22
|
gem.add_development_dependency 'rspec-its'
|
23
|
-
gem.add_development_dependency 'rubocop'
|
23
|
+
gem.add_development_dependency 'rubocop', '0.52.1'
|
24
24
|
gem.add_development_dependency 'rubysl', '~> 2.0' if RUBY_ENGINE == 'rbx'
|
25
25
|
gem.add_development_dependency 'sqlite3'
|
26
26
|
gem.add_development_dependency 'uuidtools'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "activesupport", "~> 5.2.0"
|
6
|
+
gem "activemodel", "~> 5.2.0"
|
7
|
+
gem "activerecord", "~> 5.2.0"
|
8
|
+
|
9
|
+
group :test do
|
10
|
+
gem "guard"
|
11
|
+
gem "guard-rspec"
|
12
|
+
end
|
13
|
+
|
14
|
+
gemspec path: "../"
|
data/lib/active_data/config.rb
CHANGED
@@ -2,7 +2,7 @@ module ActiveData
|
|
2
2
|
class Config
|
3
3
|
include Singleton
|
4
4
|
|
5
|
-
attr_accessor :include_root_in_json, :i18n_scope, :logger, :primary_attribute,
|
5
|
+
attr_accessor :include_root_in_json, :i18n_scope, :logger, :primary_attribute, :base_class,
|
6
6
|
:_normalizers, :_typecasters
|
7
7
|
|
8
8
|
def self.delegated
|
@@ -7,7 +7,7 @@ module ActiveData
|
|
7
7
|
if block
|
8
8
|
options[:class] = proc do |reflection|
|
9
9
|
superclass = reflection.options[:class_name].to_s.presence.try(:constantize)
|
10
|
-
klass = Class.new(superclass || ActiveData
|
10
|
+
klass = Class.new(superclass || ActiveData.base_class) do
|
11
11
|
include ActiveData::Model
|
12
12
|
include ActiveData::Model::Associations
|
13
13
|
include ActiveData::Model::Lifecycle
|
@@ -16,34 +16,39 @@ module ActiveData
|
|
16
16
|
def self.included(_base); end
|
17
17
|
end
|
18
18
|
|
19
|
+
include DIRTY_CLONE
|
20
|
+
|
19
21
|
included do
|
20
|
-
|
22
|
+
attribute_names(false).each do |name|
|
23
|
+
define_dirty name, generated_attributes_methods
|
24
|
+
end
|
25
|
+
_attribute_aliases.each_key do |name|
|
26
|
+
define_dirty name, generated_attributes_methods
|
27
|
+
end
|
28
|
+
end
|
21
29
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
private :set_attribute_was
|
30
|
+
if !method_defined?(:set_attribute_was) && !private_method_defined?(:set_attribute_was)
|
31
|
+
private def set_attribute_was(attr, old_value)
|
32
|
+
changed_attributes[attr] = old_value
|
27
33
|
end
|
34
|
+
end
|
28
35
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
36
|
+
unless method_defined?(:clear_changes_information)
|
37
|
+
if method_defined?(:reset_changes)
|
38
|
+
def clear_changes_information
|
39
|
+
reset_changes
|
40
|
+
end
|
41
|
+
else
|
42
|
+
def clear_changes_information
|
43
|
+
@previously_changed = nil
|
44
|
+
@changed_attributes = nil
|
39
45
|
end
|
40
46
|
end
|
47
|
+
end
|
41
48
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
_attribute_aliases.each_key do |name|
|
46
|
-
define_dirty name, generated_attributes_methods
|
49
|
+
unless method_defined?(:_read_attribute)
|
50
|
+
def _read_attribute(attr)
|
51
|
+
__send__(attr)
|
47
52
|
end
|
48
53
|
end
|
49
54
|
|
data/lib/active_data/version.rb
CHANGED
data/lib/active_data.rb
CHANGED
@@ -53,7 +53,7 @@ describe ActiveData::Model::Associations::Validations do
|
|
53
53
|
specify { expect(user.validate).to eq(false) }
|
54
54
|
specify do
|
55
55
|
expect { user.validate }.to change { user.errors.messages }
|
56
|
-
.to(
|
56
|
+
.to('projects.0.author.name': ["can't be blank"])
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -70,7 +70,7 @@ describe ActiveData::Model::Associations::Validations do
|
|
70
70
|
specify { expect(user.validate).to eq(false) }
|
71
71
|
specify do
|
72
72
|
expect { user.validate }.to change { user.errors.messages }
|
73
|
-
.to(
|
73
|
+
.to('projects.1.title': ["can't be blank"])
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -98,7 +98,7 @@ describe ActiveData::Model::Associations::Validations do
|
|
98
98
|
specify { expect(user.invalid_ancestry?).to eq(true) }
|
99
99
|
specify do
|
100
100
|
expect { user.validate_ancestry }.to change { user.errors.messages }
|
101
|
-
.to(
|
101
|
+
.to('projects.0.author.name': ["can't be blank"])
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -110,7 +110,7 @@ describe ActiveData::Model::Associations::Validations do
|
|
110
110
|
specify { expect(user.invalid_ancestry?).to eq(true) }
|
111
111
|
specify do
|
112
112
|
expect { user.validate_ancestry }.to change { user.errors.messages }
|
113
|
-
.to(
|
113
|
+
.to('profile.first_name': ["can't be blank"])
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
@@ -122,14 +122,14 @@ describe ActiveData::Model::Associations::Validations do
|
|
122
122
|
specify { expect(user.invalid_ancestry?).to eq(true) }
|
123
123
|
specify do
|
124
124
|
expect { user.validate_ancestry }.to change { user.errors.messages }
|
125
|
-
.to(
|
125
|
+
.to('projects.1.title': ["can't be blank"])
|
126
126
|
end
|
127
127
|
|
128
128
|
context do
|
129
129
|
before { user.update(login: '') }
|
130
130
|
specify do
|
131
131
|
expect { user.validate_ancestry }.to change { user.errors.messages }
|
132
|
-
.to(
|
132
|
+
.to('projects.1.title': ["can't be blank"], login: ["can't be blank"])
|
133
133
|
end
|
134
134
|
end
|
135
135
|
end
|
@@ -120,7 +120,7 @@ describe ActiveData::Model::Representation do
|
|
120
120
|
|
121
121
|
specify do
|
122
122
|
expect { post.validate }.to change { post.errors.messages }
|
123
|
-
.to(hash_including(
|
123
|
+
.to(hash_including('author.user.email': ['is invalid'], name: ["can't be blank"]))
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
@@ -68,7 +68,7 @@ describe ActiveData::Model::Validations::AssociatedValidator do
|
|
68
68
|
it { is_expected.not_to be_valid }
|
69
69
|
specify do
|
70
70
|
expect { instance.validate }.to change { instance.errors.messages }
|
71
|
-
.to(
|
71
|
+
.to('validated_many.0.name': ["can't be blank"], validated_many: ['is invalid'])
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -96,7 +96,7 @@ describe ActiveData::Model::Validations::AssociatedValidator do
|
|
96
96
|
it { is_expected.not_to be_valid }
|
97
97
|
specify do
|
98
98
|
expect { instance.validate }.to change { instance.errors.messages }
|
99
|
-
.to(
|
99
|
+
.to('validated_many.0.name': ["can't be blank"], validated_many: ['is invalid'])
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
@@ -45,7 +45,7 @@ describe ActiveData::Model::Validations::NestedValidator do
|
|
45
45
|
it { is_expected.not_to be_valid }
|
46
46
|
specify do
|
47
47
|
expect { instance.validate }.to change { instance.errors.messages }
|
48
|
-
.to(
|
48
|
+
.to('validated_one.name': ["can't be blank"])
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -69,7 +69,7 @@ describe ActiveData::Model::Validations::NestedValidator do
|
|
69
69
|
it { is_expected.not_to be_valid }
|
70
70
|
specify do
|
71
71
|
expect { instance.validate }.to change { instance.errors.messages }
|
72
|
-
.to(
|
72
|
+
.to('validated_many.0.name': ["can't be blank"])
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -88,7 +88,7 @@ describe ActiveData::Model::Validations::NestedValidator do
|
|
88
88
|
it { is_expected.not_to be_valid }
|
89
89
|
specify do
|
90
90
|
expect { instance.validate }.to change { instance.errors.messages }
|
91
|
-
.to(
|
91
|
+
.to('validated_one.name': ["can't be blank"])
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -152,7 +152,7 @@ describe ActiveData::Model::Validations::NestedValidator do
|
|
152
152
|
it { is_expected.not_to be_valid }
|
153
153
|
specify do
|
154
154
|
expect { instance.validate }.to change { instance.errors.messages }
|
155
|
-
.to(
|
155
|
+
.to('validated_many.0.name': ["can't be blank"])
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pyromaniac
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: rubocop
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.52.1
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.52.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: sqlite3
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,7 +190,6 @@ files:
|
|
190
190
|
- ".rspec"
|
191
191
|
- ".rubocop.yml"
|
192
192
|
- ".rubocop_todo.yml"
|
193
|
-
- ".rvmrc"
|
194
193
|
- ".travis.yml"
|
195
194
|
- Appraisals
|
196
195
|
- CHANGELOG.md
|
@@ -205,6 +204,7 @@ files:
|
|
205
204
|
- gemfiles/rails.4.2.gemfile
|
206
205
|
- gemfiles/rails.5.0.gemfile
|
207
206
|
- gemfiles/rails.5.1.gemfile
|
207
|
+
- gemfiles/rails.5.2.gemfile
|
208
208
|
- lib/active_data.rb
|
209
209
|
- lib/active_data/active_record/associations.rb
|
210
210
|
- lib/active_data/active_record/nested_attributes.rb
|
@@ -333,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
333
333
|
version: '0'
|
334
334
|
requirements: []
|
335
335
|
rubyforge_project:
|
336
|
-
rubygems_version: 2.7.
|
336
|
+
rubygems_version: 2.7.6
|
337
337
|
signing_key:
|
338
338
|
specification_version: 4
|
339
339
|
summary: Working with hashes in AR style
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm use --create 2.4@active_data
|