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
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
M2M1NGZjZDNhOTVjNTBkYTE1YWI4M2Y4ZmRiYmJhNzViNjg3MzQ5MQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dbfd04fe687681f1030ef93cbbf32c177bb67f98
|
4
|
+
data.tar.gz: b2e7ff76d84de665db33f2275e082ad6dc24122c
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NDJkYTRmZjE1MzdhMGU4M2M0NzkzZmEyNjgyN2IzZmY1YzA3NGMxN2MxMWFj
|
11
|
-
NjdhNDUwMWVlMmVjY2RhODk0OTY4M2I3YjM4ZTAzMDlhMzVjMjI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YjVkZGQyMmNkYmQ1ZjkwMjc0ZjAwZDgwNTBlYmM0YzJhMjA0YTc5ZmYxMzQ2
|
14
|
-
ZGJiMDhmODFmY2ExY2Q1OWFmNGMzYzRlMGNlM2EwNmVmM2FkOTJjODBkODBm
|
15
|
-
OTAzNDRmODkwMTg4MzA2NGNkOTk1ZDViMjQ4NThlMjhhM2Q3YTY=
|
6
|
+
metadata.gz: 416ef86c1c665c0a20ef9a9efd78ed2ab21cacd7b254bbf5282e63cf54f214bb0757020f145a404730d0c63fd6fbd06a8457461d833f706c1a7a1c3e34e61ea8
|
7
|
+
data.tar.gz: 878e0a1ce4a1fbcabf50ac95dd2e7090f6f21548bf19b559fca4b1dc49ce0c939d76ca28da737cc6414c384f972a13126935dc73e2f4c9f63256a8dd83d2f92f
|
data/.gitignore
CHANGED
@@ -1,19 +1,50 @@
|
|
1
1
|
*.gem
|
2
2
|
*.rbc
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
## Specific to RubyMotion:
|
14
|
+
.dat*
|
15
|
+
.repl_history
|
16
|
+
build/
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalization:
|
25
|
+
/.bundle/
|
26
|
+
/vendor/bundle
|
27
|
+
/lib/bundler/man/
|
28
|
+
|
29
|
+
# for a library or gem, you might want to ignore these files since the code is
|
30
|
+
# intended to run in multiple environments; otherwise, check them in:
|
31
|
+
# Gemfile.lock
|
32
|
+
# .ruby-version
|
33
|
+
.ruby-gemset
|
34
|
+
|
35
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
36
|
+
.rvmrc
|
37
|
+
|
38
|
+
*.bundle
|
39
|
+
*.so
|
40
|
+
*.o
|
41
|
+
*.a
|
42
|
+
mkmf.log
|
43
|
+
|
44
|
+
.DS_Store
|
45
|
+
|
46
|
+
# Jetbrains Idea files
|
47
|
+
.idea/
|
48
|
+
api.iml
|
49
|
+
|
50
|
+
db/schema.rb
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Style/EmptyLinesAroundClassBody:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Style/EmptyLinesAroundModuleBody:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Style/FrozenStringLiteralComment:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
AllCops:
|
11
|
+
DisplayCopNames: true
|
12
|
+
Exclude:
|
13
|
+
- 'spec/**/*'
|
14
|
+
- 'Gemfile*'
|
15
|
+
- '*.gemspec'
|
16
|
+
- 'vendor/**/*'
|
17
|
+
|
18
|
+
Documentation:
|
19
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.0
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,16 +1,3 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in object_attorney.gemspec
|
4
3
|
gemspec
|
5
|
-
|
6
|
-
group :development, :test do
|
7
|
-
gem "rspec", "~> 2.11"
|
8
|
-
gem "sqlite3"
|
9
|
-
gem "activerecord"
|
10
|
-
#gem 'database_cleaner'
|
11
|
-
gem "pry"
|
12
|
-
|
13
|
-
unless ENV["CI"]
|
14
|
-
gem "guard-rspec", "~> 0.7"
|
15
|
-
end
|
16
|
-
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
object_attorney (3.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (4.2.6)
|
10
|
+
activesupport (= 4.2.6)
|
11
|
+
builder (~> 3.1)
|
12
|
+
activesupport (4.2.6)
|
13
|
+
i18n (~> 0.7)
|
14
|
+
json (~> 1.7, >= 1.7.7)
|
15
|
+
minitest (~> 5.1)
|
16
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
17
|
+
tzinfo (~> 1.1)
|
18
|
+
ast (2.3.0)
|
19
|
+
builder (3.2.2)
|
20
|
+
codeclimate-test-reporter (0.4.8)
|
21
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
22
|
+
coderay (1.1.1)
|
23
|
+
diff-lcs (1.2.5)
|
24
|
+
docile (1.1.5)
|
25
|
+
i18n (0.7.0)
|
26
|
+
json (1.8.3)
|
27
|
+
method_source (0.8.2)
|
28
|
+
minitest (5.9.0)
|
29
|
+
parser (2.3.1.2)
|
30
|
+
ast (~> 2.2)
|
31
|
+
powerpack (0.1.1)
|
32
|
+
pry (0.10.3)
|
33
|
+
coderay (~> 1.1.0)
|
34
|
+
method_source (~> 0.8.1)
|
35
|
+
slop (~> 3.4)
|
36
|
+
rainbow (2.1.0)
|
37
|
+
rake (11.2.2)
|
38
|
+
rspec (3.4.0)
|
39
|
+
rspec-core (~> 3.4.0)
|
40
|
+
rspec-expectations (~> 3.4.0)
|
41
|
+
rspec-mocks (~> 3.4.0)
|
42
|
+
rspec-core (3.4.4)
|
43
|
+
rspec-support (~> 3.4.0)
|
44
|
+
rspec-expectations (3.4.0)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.4.0)
|
47
|
+
rspec-mocks (3.4.1)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.4.0)
|
50
|
+
rspec-support (3.4.1)
|
51
|
+
rubocop (0.37.2)
|
52
|
+
parser (>= 2.3.0.4, < 3.0)
|
53
|
+
powerpack (~> 0.1)
|
54
|
+
rainbow (>= 1.99.1, < 3.0)
|
55
|
+
ruby-progressbar (~> 1.7)
|
56
|
+
unicode-display_width (~> 0.3)
|
57
|
+
ruby-progressbar (1.8.1)
|
58
|
+
simplecov (0.11.2)
|
59
|
+
docile (~> 1.1.0)
|
60
|
+
json (~> 1.8)
|
61
|
+
simplecov-html (~> 0.10.0)
|
62
|
+
simplecov-html (0.10.0)
|
63
|
+
slop (3.6.0)
|
64
|
+
thread_safe (0.3.5)
|
65
|
+
tzinfo (1.2.2)
|
66
|
+
thread_safe (~> 0.1)
|
67
|
+
unicode-display_width (0.3.1)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
ruby
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
activemodel (= 4.2.6)
|
74
|
+
codeclimate-test-reporter (= 0.4.8)
|
75
|
+
object_attorney!
|
76
|
+
pry (= 0.10.3)
|
77
|
+
rake (= 11.2.2)
|
78
|
+
rspec (= 3.4.0)
|
79
|
+
rubocop (= 0.37.2)
|
80
|
+
simplecov (= 0.11.2)
|
81
|
+
|
82
|
+
BUNDLED WITH
|
83
|
+
1.12.5
|
data/README.md
CHANGED
@@ -1,29 +1,36 @@
|
|
1
|
-
#
|
1
|
+
# Object Attorney
|
2
2
|
|
3
|
-
TODO: Write a gem description
|
4
3
|
|
5
|
-
|
4
|
+
[![Code Climate](https://codeclimate.com/github/goncalvesjoao/object_attorney/badges/gpa.svg)](https://codeclimate.com/github/goncalvesjoao/object_attorney)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/goncalvesjoao/object_attorney/badges/coverage.svg)](https://codeclimate.com/github/goncalvesjoao/object_attorney/coverage)
|
6
|
+
[![Build Status](https://travis-ci.org/goncalvesjoao/object_attorney.svg?branch=master)](https://travis-ci.org/goncalvesjoao/object_attorney)
|
6
7
|
|
7
|
-
|
8
|
+
## 1) Basic Usage
|
9
|
+
```ruby
|
10
|
+
class User < Struct.new(:title, :first_name, :last_name)
|
11
|
+
end
|
12
|
+
```
|
8
13
|
|
9
|
-
|
14
|
+
```ruby
|
15
|
+
class UserValidator < Struct.new(:user)
|
16
|
+
include ObjectAttorney
|
10
17
|
|
11
|
-
|
18
|
+
defend :user
|
12
19
|
|
13
|
-
|
20
|
+
validates_presence_of :first_name
|
21
|
+
end
|
14
22
|
|
15
|
-
|
23
|
+
# OR
|
16
24
|
|
17
|
-
|
25
|
+
class UserValidator < ObjectAttorney::Base
|
26
|
+
validates_presence_of :first_name
|
27
|
+
end
|
28
|
+
```
|
18
29
|
|
19
|
-
|
30
|
+
```ruby
|
31
|
+
@user = User.new
|
20
32
|
|
21
|
-
|
33
|
+
UserValidator.new(@user).valid?
|
22
34
|
|
23
|
-
|
24
|
-
|
25
|
-
1. Fork it
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
35
|
+
@user.errors.messages # { first_name: ["can't be blank"] }
|
36
|
+
```
|
data/Rakefile
CHANGED
@@ -1,19 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
# require 'yaml'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'rubocop/rake_task'
|
6
5
|
|
7
|
-
|
6
|
+
RSpec::Core::RakeTask.new
|
7
|
+
RuboCop::RakeTask.new
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
# desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
|
12
|
-
# task :migrate => :environment do
|
13
|
-
# ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
|
14
|
-
# end
|
15
|
-
|
16
|
-
# task :environment do
|
17
|
-
# ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yml'))[ENV["RAILS_ENV"]])
|
18
|
-
# ActiveRecord::Base.logger = Logger.new(File.open('tmp/database.log', 'a'))
|
19
|
-
# end
|
9
|
+
task(:default).clear
|
10
|
+
task default: [:rubocop, :spec]
|
data/lib/object_attorney.rb
CHANGED
@@ -1,66 +1,79 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require "object_attorney/naming"
|
6
|
-
require "object_attorney/reflection"
|
7
|
-
require "object_attorney/validations"
|
8
|
-
require "object_attorney/nested_objects"
|
9
|
-
require "object_attorney/record"
|
10
|
-
require "object_attorney/translation"
|
11
|
-
require "object_attorney/representation"
|
12
|
-
require "object_attorney/serialization"
|
13
|
-
require 'active_record'
|
14
|
-
|
15
|
-
require "object_attorney/version"
|
1
|
+
require 'active_model'
|
2
|
+
require 'object_attorney/version'
|
3
|
+
require 'object_attorney/helpers'
|
4
|
+
require 'object_attorney/class_methods'
|
16
5
|
|
17
6
|
module ObjectAttorney
|
18
7
|
|
19
|
-
def
|
20
|
-
|
8
|
+
def self.included(base_class)
|
9
|
+
base_class.extend ClassMethods
|
10
|
+
base_class.extend ActiveModel::Validations::HelperMethods
|
11
|
+
end
|
21
12
|
|
22
|
-
|
13
|
+
def defendant_is_innocent?
|
14
|
+
proven_innocent = defendants.all? do |defendant|
|
15
|
+
innocent_of_all_accusations?(defendant)
|
16
|
+
end
|
23
17
|
|
24
|
-
|
18
|
+
make_the_parent_guilty unless proven_innocent
|
25
19
|
|
26
|
-
|
20
|
+
proven_innocent
|
21
|
+
end
|
27
22
|
|
28
|
-
|
23
|
+
alias valid? defendant_is_innocent?
|
29
24
|
|
30
|
-
|
25
|
+
def invalid?
|
26
|
+
!valid?
|
31
27
|
end
|
32
28
|
|
33
|
-
protected
|
29
|
+
protected ######################### PROTECTED ################################
|
34
30
|
|
35
|
-
def
|
31
|
+
def defendants
|
32
|
+
defendant = Helpers.safe_call_method(self, defendant_options[:name])
|
36
33
|
|
37
|
-
|
34
|
+
if parent_defendant
|
35
|
+
Helpers.extend_errors_if_necessary(parent_defendant)
|
38
36
|
|
39
|
-
|
37
|
+
defendant ||= parent_defendant.send(defendant_options[:name])
|
38
|
+
end
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
include ActiveModel::Validations
|
44
|
-
include ActiveModel::Validations::Callbacks
|
45
|
-
include ActiveModel::Conversion
|
40
|
+
[defendant].flatten.compact
|
41
|
+
end
|
46
42
|
|
47
|
-
|
48
|
-
|
49
|
-
include NestedObjects
|
50
|
-
include Record
|
51
|
-
include Representation
|
52
|
-
include Serialization
|
43
|
+
def innocent_of_all_accusations?(defendant)
|
44
|
+
Helpers.extend_errors_if_necessary(defendant)
|
53
45
|
|
54
|
-
|
55
|
-
|
46
|
+
return true if Helpers.marked_for_destruction?(defendant)
|
47
|
+
|
48
|
+
founded_accusations(defendant).all?(&:sustained?)
|
49
|
+
|
50
|
+
defendant.errors.empty?
|
51
|
+
end
|
52
|
+
|
53
|
+
def make_the_parent_guilty
|
54
|
+
return unless parent_defendant
|
56
55
|
|
57
|
-
|
56
|
+
parent_defendant.errors.add(defendant_options[:name], :invalid)
|
58
57
|
end
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
private ############################ PRIVATE #################################
|
60
|
+
|
61
|
+
def parent_defendant
|
62
|
+
return nil unless defendant_options[:in]
|
63
|
+
|
64
|
+
@parent_defendant ||= send(defendant_options[:in])
|
65
|
+
end
|
66
|
+
|
67
|
+
def defendant_options
|
68
|
+
self.class.defendant_options
|
69
|
+
end
|
70
|
+
|
71
|
+
def founded_accusations(defendant)
|
72
|
+
self.class.allegations.values.flatten.uniq.map do |allegation|
|
73
|
+
allegation.founded_accusation(self, defendant)
|
74
|
+
end.compact
|
64
75
|
end
|
65
76
|
|
66
77
|
end
|
78
|
+
|
79
|
+
require 'object_attorney/base'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module ObjectAttorney
|
2
|
+
|
3
|
+
class Accusation
|
4
|
+
|
5
|
+
def initialize(validation, attorney, defendant)
|
6
|
+
@attorney = attorney
|
7
|
+
@defendant = defendant
|
8
|
+
@validation = validation
|
9
|
+
end
|
10
|
+
|
11
|
+
def sustained?
|
12
|
+
@validation.attorney = @attorney if @validation.respond_to?(:attorney=)
|
13
|
+
|
14
|
+
# expected to be an ActiveModel::Validations::<Class> instance
|
15
|
+
@validation.validate(@defendant)
|
16
|
+
end
|
17
|
+
|
18
|
+
def founded
|
19
|
+
return true if options[:if].nil? && options[:unless].nil?
|
20
|
+
|
21
|
+
if_condition_true || unless_condition_true
|
22
|
+
end
|
23
|
+
|
24
|
+
protected ######################## PROTECTED ###############################
|
25
|
+
|
26
|
+
def if_condition_true
|
27
|
+
return nil if options[:if].nil?
|
28
|
+
|
29
|
+
Helpers.call_proc_or_method(@attorney, options[:if], @defendant)
|
30
|
+
end
|
31
|
+
|
32
|
+
def unless_condition_true
|
33
|
+
return nil if options[:unless].nil?
|
34
|
+
|
35
|
+
!Helpers.call_proc_or_method(@attorney, options[:unless], @defendant)
|
36
|
+
end
|
37
|
+
|
38
|
+
private ########################### PRIVATE ################################
|
39
|
+
|
40
|
+
def options
|
41
|
+
@validation.options
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|