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.
Files changed (87) hide show
  1. checksums.yaml +5 -13
  2. data/.gitignore +48 -17
  3. data/.rubocop.yml +19 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +4 -0
  6. data/Gemfile +0 -13
  7. data/Gemfile.lock +83 -0
  8. data/README.md +25 -18
  9. data/Rakefile +7 -16
  10. data/lib/object_attorney.rb +57 -44
  11. data/lib/object_attorney/accusation.rb +46 -0
  12. data/lib/object_attorney/allegation.rb +20 -0
  13. data/lib/object_attorney/base.rb +17 -0
  14. data/lib/object_attorney/class_methods.rb +50 -0
  15. data/lib/object_attorney/errors.rb +32 -0
  16. data/lib/object_attorney/helpers.rb +22 -21
  17. data/lib/object_attorney/validations/custom.rb +23 -0
  18. data/lib/object_attorney/version.rb +3 -1
  19. data/object_attorney.gemspec +24 -17
  20. data/spec/object_attorney/base_spec.rb +21 -0
  21. data/spec/object_attorney/custom_validation_spec.rb +60 -0
  22. data/spec/object_attorney/object_attorney_spec.rb +64 -0
  23. data/spec/spec_helper.rb +17 -56
  24. data/spec/support/post.rb +7 -0
  25. data/spec/support/user.rb +5 -0
  26. metadata +102 -127
  27. data/.rvmrc +0 -1
  28. data/Guardfile +0 -5
  29. data/console.rb +0 -36
  30. data/db/migrate/20131205114000_create_users.rb +0 -13
  31. data/db/migrate/20131205114900_create_posts.rb +0 -14
  32. data/db/migrate/20131205114901_create_comments.rb +0 -13
  33. data/db/migrate/20131205114902_create_addresses.rb +0 -14
  34. data/db/schema.rb +0 -22
  35. data/lib/object_attorney/association_reflection.rb +0 -72
  36. data/lib/object_attorney/attribute_assignment.rb +0 -69
  37. data/lib/object_attorney/delegation.rb +0 -48
  38. data/lib/object_attorney/naming.rb +0 -16
  39. data/lib/object_attorney/nested_objects.rb +0 -311
  40. data/lib/object_attorney/orm_handlers/smooth_operator.rb +0 -69
  41. data/lib/object_attorney/record.rb +0 -117
  42. data/lib/object_attorney/reflection.rb +0 -40
  43. data/lib/object_attorney/representation.rb +0 -93
  44. data/lib/object_attorney/serialization.rb +0 -43
  45. data/lib/object_attorney/translation.rb +0 -25
  46. data/lib/object_attorney/validations.rb +0 -46
  47. data/not_used/nested_uniqueness_validator.rb +0 -33
  48. data/spec/object_attorney/address_form_spec.rb +0 -45
  49. data/spec/object_attorney/bulk_post_form_spec.rb +0 -52
  50. data/spec/object_attorney/bulk_posts_allow_only_existing_form_spec.rb +0 -37
  51. data/spec/object_attorney/bulk_posts_allow_only_new_form_spec.rb +0 -39
  52. data/spec/object_attorney/bulk_posts_with_form_objects_form_spec.rb +0 -91
  53. data/spec/object_attorney/delegation_spec.rb +0 -142
  54. data/spec/object_attorney/nested_objects_spec.rb +0 -63
  55. data/spec/object_attorney/post_form_spec.rb +0 -154
  56. data/spec/object_attorney/post_validations_form_spec.rb +0 -46
  57. data/spec/object_attorney/post_with_comment_form_spec.rb +0 -123
  58. data/spec/object_attorney/post_with_comment_validations_form_spec.rb +0 -46
  59. data/spec/object_attorney/post_with_comments_and_address_form_spec.rb +0 -54
  60. data/spec/object_attorney/post_with_only_existing_comments_form_spec.rb +0 -38
  61. data/spec/object_attorney/post_with_only_new_comments_form_spec.rb +0 -42
  62. data/spec/object_attorney/serialization_spec.rb +0 -40
  63. data/spec/object_attorney/test_spec.rb +0 -23
  64. data/spec/object_attorney/user_and_comments_form_spec.rb +0 -56
  65. data/spec/object_attorney/user_form_spec.rb +0 -70
  66. data/spec/require_helper.rb +0 -32
  67. data/spec/support/active_model/validations.rb +0 -21
  68. data/spec/support/database_setup.rb +0 -14
  69. data/spec/support/form_objects/address_form.rb +0 -9
  70. data/spec/support/form_objects/bulk_posts_allow_only_existing_form.rb +0 -19
  71. data/spec/support/form_objects/bulk_posts_allow_only_new_form.rb +0 -19
  72. data/spec/support/form_objects/bulk_posts_form.rb +0 -27
  73. data/spec/support/form_objects/bulk_posts_with_form_objects_form.rb +0 -27
  74. data/spec/support/form_objects/comment_form.rb +0 -11
  75. data/spec/support/form_objects/post_form.rb +0 -120
  76. data/spec/support/form_objects/post_validations_form.rb +0 -17
  77. data/spec/support/form_objects/post_with_comment_form.rb +0 -21
  78. data/spec/support/form_objects/post_with_comment_validations_form.rb +0 -17
  79. data/spec/support/form_objects/post_with_comments_and_address_form.rb +0 -13
  80. data/spec/support/form_objects/post_with_only_existing_comments_form.rb +0 -9
  81. data/spec/support/form_objects/post_with_only_new_comments_form.rb +0 -9
  82. data/spec/support/form_objects/user_and_comments_form.rb +0 -11
  83. data/spec/support/form_objects/user_form.rb +0 -11
  84. data/spec/support/models/address.rb +0 -5
  85. data/spec/support/models/comment.rb +0 -5
  86. data/spec/support/models/post.rb +0 -9
  87. data/spec/support/models/user.rb +0 -7
@@ -1,17 +0,0 @@
1
- class PostValidationsForm
2
-
3
- include ObjectAttorney
4
-
5
- represents :post, properties: [:title, :body]
6
-
7
- has_many :comments
8
-
9
- validates_presence_of :title
10
-
11
- def submit
12
- post.errors.add(:title, :blank)
13
- post.comments.first.errors.add(:body, :blank)
14
- false
15
- end
16
-
17
- end
@@ -1,21 +0,0 @@
1
- module PostWithCommentForm
2
-
3
- class Base < PostForm::Base
4
-
5
- has_many :comments, class_name: CommentForm
6
-
7
- end
8
-
9
- class Explicit < PostForm::Base
10
-
11
- def build_comment(attributes = {})
12
- CommentForm.new(attributes)
13
- end
14
-
15
- def existing_comments
16
- post.comments.map { |comment| CommentForm.new({}, comment) }
17
- end
18
-
19
- end
20
-
21
- end
@@ -1,17 +0,0 @@
1
- class PostWithCommentValidationsForm
2
-
3
- include ObjectAttorney
4
-
5
- represents :post, properties: [:title, :body]
6
-
7
- has_many :comments, class_name: CommentForm
8
-
9
- validates_presence_of :title
10
-
11
- def submit
12
- post.errors.add(:title, :blank)
13
- post.comments.first.errors.add(:body, :blank)
14
- false
15
- end
16
-
17
- end
@@ -1,13 +0,0 @@
1
- class PostWithCommentsAndAddressForm
2
-
3
- include ObjectAttorney
4
-
5
- represents :post, properties: [:title, :body]
6
-
7
- has_many :comments
8
-
9
- has_one :address
10
-
11
- validates_presence_of :title
12
-
13
- end
@@ -1,9 +0,0 @@
1
- class PostWithOnlyExistingCommentsForm
2
-
3
- include ObjectAttorney
4
-
5
- represents :post, properties: [:title, :body]
6
-
7
- has_many :comments, new_records: false
8
-
9
- end
@@ -1,9 +0,0 @@
1
- class PostWithOnlyNewCommentsForm
2
-
3
- include ObjectAttorney
4
-
5
- represents :post, properties: [:title, :body]
6
-
7
- has_many :comments, existing_records: false
8
-
9
- end
@@ -1,11 +0,0 @@
1
- class UserAndCommentsForm
2
-
3
- include ObjectAttorney
4
-
5
- represents :user, properties: [:email]
6
-
7
- has_many :comments, class_name: CommentForm, standalone: true
8
-
9
- has_one :address, standalone: true
10
-
11
- end
@@ -1,11 +0,0 @@
1
- class UserForm
2
-
3
- include ObjectAttorney
4
-
5
- represents :user, properties: [:email]
6
-
7
- attr_accessor :terms_of_service
8
-
9
- validates_acceptance_of :terms_of_service, accept: true, allow_nil: false
10
-
11
- end
@@ -1,5 +0,0 @@
1
- class Address < ActiveRecord::Base
2
-
3
- belongs_to :post
4
-
5
- end
@@ -1,5 +0,0 @@
1
- class Comment < ActiveRecord::Base
2
-
3
- belongs_to :post
4
-
5
- end
@@ -1,9 +0,0 @@
1
- class Post < ActiveRecord::Base
2
-
3
- has_many :comments
4
-
5
- has_one :address
6
-
7
- belongs_to :user
8
-
9
- end
@@ -1,7 +0,0 @@
1
- class User < ActiveRecord::Base
2
-
3
- has_many :posts
4
-
5
- validates_presence_of :email
6
-
7
- end