Module: ObjectAttorney

Included in:
Base
Defined in:
lib/object_attorney.rb,
lib/object_attorney/base.rb,
lib/object_attorney/errors.rb,
lib/object_attorney/helpers.rb,
lib/object_attorney/version.rb,
lib/object_attorney/accusation.rb,
lib/object_attorney/allegation.rb,
lib/object_attorney/class_methods.rb,
lib/object_attorney/validations/custom.rb

Defined Under Namespace

Modules: ClassMethods, Errors, Helpers, Validations Classes: Accusation, Allegation, Base

Constant Summary collapse

VERSION =
'3.1.1'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base_class) ⇒ Object



8
9
10
11
# File 'lib/object_attorney.rb', line 8

def self.included(base_class)
  base_class.extend ClassMethods
  base_class.extend ActiveModel::Validations::HelperMethods
end

Instance Method Details

#defendant_is_innocent?Boolean Also known as: valid?

Returns:

  • (Boolean)

Raises:



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/object_attorney.rb', line 13

def defendant_is_innocent?
  raise Errors::NoDefendantToDefendError if defendant_options.empty?

  proven_innocent = defendants.map do |defendant|
    innocent_of_all_accusations?(defendant)
  end.all?

  make_the_parent_guilty unless proven_innocent

  proven_innocent
end

#invalid?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/object_attorney.rb', line 27

def invalid?
  !valid?
end