object_attorney 2.10.12 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +48 -17
- data/.rubocop.yml +19 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +0 -13
- data/Gemfile.lock +83 -0
- data/README.md +25 -18
- data/Rakefile +7 -16
- data/lib/object_attorney.rb +57 -44
- data/lib/object_attorney/accusation.rb +46 -0
- data/lib/object_attorney/allegation.rb +20 -0
- data/lib/object_attorney/base.rb +17 -0
- data/lib/object_attorney/class_methods.rb +50 -0
- data/lib/object_attorney/errors.rb +32 -0
- data/lib/object_attorney/helpers.rb +22 -21
- data/lib/object_attorney/validations/custom.rb +23 -0
- data/lib/object_attorney/version.rb +3 -1
- data/object_attorney.gemspec +24 -17
- data/spec/object_attorney/base_spec.rb +21 -0
- data/spec/object_attorney/custom_validation_spec.rb +60 -0
- data/spec/object_attorney/object_attorney_spec.rb +64 -0
- data/spec/spec_helper.rb +17 -56
- data/spec/support/post.rb +7 -0
- data/spec/support/user.rb +5 -0
- metadata +102 -127
- data/.rvmrc +0 -1
- data/Guardfile +0 -5
- data/console.rb +0 -36
- data/db/migrate/20131205114000_create_users.rb +0 -13
- data/db/migrate/20131205114900_create_posts.rb +0 -14
- data/db/migrate/20131205114901_create_comments.rb +0 -13
- data/db/migrate/20131205114902_create_addresses.rb +0 -14
- data/db/schema.rb +0 -22
- data/lib/object_attorney/association_reflection.rb +0 -72
- data/lib/object_attorney/attribute_assignment.rb +0 -69
- data/lib/object_attorney/delegation.rb +0 -48
- data/lib/object_attorney/naming.rb +0 -16
- data/lib/object_attorney/nested_objects.rb +0 -311
- data/lib/object_attorney/orm_handlers/smooth_operator.rb +0 -69
- data/lib/object_attorney/record.rb +0 -117
- data/lib/object_attorney/reflection.rb +0 -40
- data/lib/object_attorney/representation.rb +0 -93
- data/lib/object_attorney/serialization.rb +0 -43
- data/lib/object_attorney/translation.rb +0 -25
- data/lib/object_attorney/validations.rb +0 -46
- data/not_used/nested_uniqueness_validator.rb +0 -33
- data/spec/object_attorney/address_form_spec.rb +0 -45
- data/spec/object_attorney/bulk_post_form_spec.rb +0 -52
- data/spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb +0 -37
- data/spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb +0 -39
- data/spec/object_attorney/bulk_posts_with_form_objects_form_spec.rb +0 -91
- data/spec/object_attorney/delegation_spec.rb +0 -142
- data/spec/object_attorney/nested_objects_spec.rb +0 -63
- data/spec/object_attorney/post_form_spec.rb +0 -154
- data/spec/object_attorney/post_validations_form_spec.rb +0 -46
- data/spec/object_attorney/post_with_comment_form_spec.rb +0 -123
- data/spec/object_attorney/post_with_comment_validations_form_spec.rb +0 -46
- data/spec/object_attorney/post_with_comments_and_address_form_spec.rb +0 -54
- data/spec/object_attorney/post_with_only_existing_comments_form_spec.rb +0 -38
- data/spec/object_attorney/post_with_only_new_comments_form_spec.rb +0 -42
- data/spec/object_attorney/serialization_spec.rb +0 -40
- data/spec/object_attorney/test_spec.rb +0 -23
- data/spec/object_attorney/user_and_comments_form_spec.rb +0 -56
- data/spec/object_attorney/user_form_spec.rb +0 -70
- data/spec/require_helper.rb +0 -32
- data/spec/support/active_model/validations.rb +0 -21
- data/spec/support/database_setup.rb +0 -14
- data/spec/support/form_objects/address_form.rb +0 -9
- data/spec/support/form_objects/bulk_posts_allow_only_existing_form.rb +0 -19
- data/spec/support/form_objects/bulk_posts_allow_only_new_form.rb +0 -19
- data/spec/support/form_objects/bulk_posts_form.rb +0 -27
- data/spec/support/form_objects/bulk_posts_with_form_objects_form.rb +0 -27
- data/spec/support/form_objects/comment_form.rb +0 -11
- data/spec/support/form_objects/post_form.rb +0 -120
- data/spec/support/form_objects/post_validations_form.rb +0 -17
- data/spec/support/form_objects/post_with_comment_form.rb +0 -21
- data/spec/support/form_objects/post_with_comment_validations_form.rb +0 -17
- data/spec/support/form_objects/post_with_comments_and_address_form.rb +0 -13
- data/spec/support/form_objects/post_with_only_existing_comments_form.rb +0 -9
- data/spec/support/form_objects/post_with_only_new_comments_form.rb +0 -9
- data/spec/support/form_objects/user_and_comments_form.rb +0 -11
- data/spec/support/form_objects/user_form.rb +0 -11
- data/spec/support/models/address.rb +0 -5
- data/spec/support/models/comment.rb +0 -5
- data/spec/support/models/post.rb +0 -9
- data/spec/support/models/user.rb +0 -7
metadata
CHANGED
@@ -1,137 +1,149 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: object_attorney
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- João Gonçalves
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: pry
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.10.3
|
20
20
|
type: :development
|
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:
|
26
|
+
version: 0.10.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 11.2.2
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 11.2.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 3.4.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
|
54
|
+
version: 3.4.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.37.2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.37.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.11.2
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.11.2
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: activemodel
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 4.2.6
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 4.2.6
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: codeclimate-test-reporter
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.4.8
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.4.8
|
111
|
+
description: This gem allows you to extract the code responsible for 'validations',
|
112
|
+
'nested objects' and 'strong parameters' from your model onto a specific class for
|
113
|
+
a specific use case.
|
56
114
|
email:
|
57
115
|
- goncalves.joao@gmail.com
|
58
116
|
executables: []
|
59
117
|
extensions: []
|
60
118
|
extra_rdoc_files: []
|
61
119
|
files:
|
62
|
-
- .gitignore
|
63
|
-
- .rspec
|
64
|
-
- .
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- ".rubocop.yml"
|
123
|
+
- ".ruby-version"
|
124
|
+
- ".travis.yml"
|
65
125
|
- Gemfile
|
66
|
-
-
|
126
|
+
- Gemfile.lock
|
67
127
|
- LICENSE.txt
|
68
128
|
- README.md
|
69
129
|
- Rakefile
|
70
|
-
- console.rb
|
71
|
-
- db/migrate/20131205114000_create_users.rb
|
72
|
-
- db/migrate/20131205114900_create_posts.rb
|
73
|
-
- db/migrate/20131205114901_create_comments.rb
|
74
|
-
- db/migrate/20131205114902_create_addresses.rb
|
75
|
-
- db/schema.rb
|
76
130
|
- lib/object_attorney.rb
|
77
|
-
- lib/object_attorney/
|
78
|
-
- lib/object_attorney/
|
79
|
-
- lib/object_attorney/
|
131
|
+
- lib/object_attorney/accusation.rb
|
132
|
+
- lib/object_attorney/allegation.rb
|
133
|
+
- lib/object_attorney/base.rb
|
134
|
+
- lib/object_attorney/class_methods.rb
|
135
|
+
- lib/object_attorney/errors.rb
|
80
136
|
- lib/object_attorney/helpers.rb
|
81
|
-
- lib/object_attorney/
|
82
|
-
- lib/object_attorney/nested_objects.rb
|
83
|
-
- lib/object_attorney/orm_handlers/smooth_operator.rb
|
84
|
-
- lib/object_attorney/record.rb
|
85
|
-
- lib/object_attorney/reflection.rb
|
86
|
-
- lib/object_attorney/representation.rb
|
87
|
-
- lib/object_attorney/serialization.rb
|
88
|
-
- lib/object_attorney/translation.rb
|
89
|
-
- lib/object_attorney/validations.rb
|
137
|
+
- lib/object_attorney/validations/custom.rb
|
90
138
|
- lib/object_attorney/version.rb
|
91
|
-
- not_used/nested_uniqueness_validator.rb
|
92
139
|
- object_attorney.gemspec
|
93
|
-
- spec/object_attorney/
|
94
|
-
- spec/object_attorney/
|
95
|
-
- spec/object_attorney/
|
96
|
-
- spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
|
97
|
-
- spec/object_attorney/bulk_posts_with_form_objects_form_spec.rb
|
98
|
-
- spec/object_attorney/delegation_spec.rb
|
99
|
-
- spec/object_attorney/nested_objects_spec.rb
|
100
|
-
- spec/object_attorney/post_form_spec.rb
|
101
|
-
- spec/object_attorney/post_validations_form_spec.rb
|
102
|
-
- spec/object_attorney/post_with_comment_form_spec.rb
|
103
|
-
- spec/object_attorney/post_with_comment_validations_form_spec.rb
|
104
|
-
- spec/object_attorney/post_with_comments_and_address_form_spec.rb
|
105
|
-
- spec/object_attorney/post_with_only_existing_comments_form_spec.rb
|
106
|
-
- spec/object_attorney/post_with_only_new_comments_form_spec.rb
|
107
|
-
- spec/object_attorney/serialization_spec.rb
|
108
|
-
- spec/object_attorney/test_spec.rb
|
109
|
-
- spec/object_attorney/user_and_comments_form_spec.rb
|
110
|
-
- spec/object_attorney/user_form_spec.rb
|
111
|
-
- spec/require_helper.rb
|
140
|
+
- spec/object_attorney/base_spec.rb
|
141
|
+
- spec/object_attorney/custom_validation_spec.rb
|
142
|
+
- spec/object_attorney/object_attorney_spec.rb
|
112
143
|
- spec/spec_helper.rb
|
113
|
-
- spec/support/
|
114
|
-
- spec/support/
|
115
|
-
|
116
|
-
- spec/support/form_objects/bulk_posts_allow_only_existing_form.rb
|
117
|
-
- spec/support/form_objects/bulk_posts_allow_only_new_form.rb
|
118
|
-
- spec/support/form_objects/bulk_posts_form.rb
|
119
|
-
- spec/support/form_objects/bulk_posts_with_form_objects_form.rb
|
120
|
-
- spec/support/form_objects/comment_form.rb
|
121
|
-
- spec/support/form_objects/post_form.rb
|
122
|
-
- spec/support/form_objects/post_validations_form.rb
|
123
|
-
- spec/support/form_objects/post_with_comment_form.rb
|
124
|
-
- spec/support/form_objects/post_with_comment_validations_form.rb
|
125
|
-
- spec/support/form_objects/post_with_comments_and_address_form.rb
|
126
|
-
- spec/support/form_objects/post_with_only_existing_comments_form.rb
|
127
|
-
- spec/support/form_objects/post_with_only_new_comments_form.rb
|
128
|
-
- spec/support/form_objects/user_and_comments_form.rb
|
129
|
-
- spec/support/form_objects/user_form.rb
|
130
|
-
- spec/support/models/address.rb
|
131
|
-
- spec/support/models/comment.rb
|
132
|
-
- spec/support/models/post.rb
|
133
|
-
- spec/support/models/user.rb
|
134
|
-
homepage: https://github.com/goncalvesjoao/object_attorney
|
144
|
+
- spec/support/post.rb
|
145
|
+
- spec/support/user.rb
|
146
|
+
homepage: https://github.com/streetbees/object_attorney
|
135
147
|
licenses:
|
136
148
|
- MIT
|
137
149
|
metadata: {}
|
@@ -141,61 +153,24 @@ require_paths:
|
|
141
153
|
- lib
|
142
154
|
required_ruby_version: !ruby/object:Gem::Requirement
|
143
155
|
requirements:
|
144
|
-
- -
|
156
|
+
- - ">="
|
145
157
|
- !ruby/object:Gem::Version
|
146
158
|
version: '0'
|
147
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
160
|
requirements:
|
149
|
-
- -
|
161
|
+
- - ">="
|
150
162
|
- !ruby/object:Gem::Version
|
151
163
|
version: '0'
|
152
164
|
requirements: []
|
153
165
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.
|
166
|
+
rubygems_version: 2.5.1
|
155
167
|
signing_key:
|
156
168
|
specification_version: 4
|
157
|
-
summary:
|
158
|
-
objects' and 'strong parameters' from your model onto a specific class for a specific
|
159
|
-
use case.
|
169
|
+
summary: Ruby Form Object pattern implementation
|
160
170
|
test_files:
|
161
|
-
- spec/object_attorney/
|
162
|
-
- spec/object_attorney/
|
163
|
-
- spec/object_attorney/
|
164
|
-
- spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb
|
165
|
-
- spec/object_attorney/bulk_posts_with_form_objects_form_spec.rb
|
166
|
-
- spec/object_attorney/delegation_spec.rb
|
167
|
-
- spec/object_attorney/nested_objects_spec.rb
|
168
|
-
- spec/object_attorney/post_form_spec.rb
|
169
|
-
- spec/object_attorney/post_validations_form_spec.rb
|
170
|
-
- spec/object_attorney/post_with_comment_form_spec.rb
|
171
|
-
- spec/object_attorney/post_with_comment_validations_form_spec.rb
|
172
|
-
- spec/object_attorney/post_with_comments_and_address_form_spec.rb
|
173
|
-
- spec/object_attorney/post_with_only_existing_comments_form_spec.rb
|
174
|
-
- spec/object_attorney/post_with_only_new_comments_form_spec.rb
|
175
|
-
- spec/object_attorney/serialization_spec.rb
|
176
|
-
- spec/object_attorney/test_spec.rb
|
177
|
-
- spec/object_attorney/user_and_comments_form_spec.rb
|
178
|
-
- spec/object_attorney/user_form_spec.rb
|
179
|
-
- spec/require_helper.rb
|
171
|
+
- spec/object_attorney/base_spec.rb
|
172
|
+
- spec/object_attorney/custom_validation_spec.rb
|
173
|
+
- spec/object_attorney/object_attorney_spec.rb
|
180
174
|
- spec/spec_helper.rb
|
181
|
-
- spec/support/
|
182
|
-
- spec/support/
|
183
|
-
- spec/support/form_objects/address_form.rb
|
184
|
-
- spec/support/form_objects/bulk_posts_allow_only_existing_form.rb
|
185
|
-
- spec/support/form_objects/bulk_posts_allow_only_new_form.rb
|
186
|
-
- spec/support/form_objects/bulk_posts_form.rb
|
187
|
-
- spec/support/form_objects/bulk_posts_with_form_objects_form.rb
|
188
|
-
- spec/support/form_objects/comment_form.rb
|
189
|
-
- spec/support/form_objects/post_form.rb
|
190
|
-
- spec/support/form_objects/post_validations_form.rb
|
191
|
-
- spec/support/form_objects/post_with_comment_form.rb
|
192
|
-
- spec/support/form_objects/post_with_comment_validations_form.rb
|
193
|
-
- spec/support/form_objects/post_with_comments_and_address_form.rb
|
194
|
-
- spec/support/form_objects/post_with_only_existing_comments_form.rb
|
195
|
-
- spec/support/form_objects/post_with_only_new_comments_form.rb
|
196
|
-
- spec/support/form_objects/user_and_comments_form.rb
|
197
|
-
- spec/support/form_objects/user_form.rb
|
198
|
-
- spec/support/models/address.rb
|
199
|
-
- spec/support/models/comment.rb
|
200
|
-
- spec/support/models/post.rb
|
201
|
-
- spec/support/models/user.rb
|
175
|
+
- spec/support/post.rb
|
176
|
+
- spec/support/user.rb
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm 1.9.3@object_attorney --create
|
data/Guardfile
DELETED
data/console.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$LOAD_PATH << './'
|
4
|
-
$LOAD_PATH << './lib'
|
5
|
-
|
6
|
-
require 'spec/require_helper'
|
7
|
-
|
8
|
-
address_attributes = {
|
9
|
-
street: 'street',
|
10
|
-
city: 'city'
|
11
|
-
}
|
12
|
-
|
13
|
-
p = PostWithCommentsAndAddressForm.new(address_attributes: address_attributes)
|
14
|
-
|
15
|
-
a = AddressForm.new(post_attributes: { title: 'asd', body: 'body' })
|
16
|
-
|
17
|
-
|
18
|
-
params = {
|
19
|
-
post: {
|
20
|
-
title: 'First post',
|
21
|
-
body: 'post body',
|
22
|
-
comments_attributes: {
|
23
|
-
"0" => { body: "body1" },
|
24
|
-
"1" => { body: "body2" }
|
25
|
-
}
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
post_form = PostForm::Base.new(params[:post])
|
30
|
-
post_form.save
|
31
|
-
|
32
|
-
|
33
|
-
post_form = PostForm::Base.new(comments_attributes: { '1' => { id: 1, body: '1', _destroy: true } })
|
34
|
-
|
35
|
-
|
36
|
-
binding.pry
|
data/db/schema.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# This file is auto-generated from the current state of the database. Instead
|
2
|
-
# of editing this file, please use the migrations feature of Active Record to
|
3
|
-
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
-
#
|
5
|
-
# Note that this schema.rb definition is the authoritative source for your
|
6
|
-
# database schema. If you need to create the application database on another
|
7
|
-
# system, you should be using db:schema:load, not running all the migrations
|
8
|
-
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
9
|
-
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
10
|
-
#
|
11
|
-
# It's strongly recommended that you check this file into your version control system.
|
12
|
-
|
13
|
-
ActiveRecord::Schema.define(version: 20131020175047) do
|
14
|
-
|
15
|
-
create_table "posts", force: true do |t|
|
16
|
-
t.string "title"
|
17
|
-
t.text "body"
|
18
|
-
t.datetime "created_at"
|
19
|
-
t.datetime "updated_at"
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|