module ObjectAttorney
Constants
- VERSION
Public Class Methods
included(base_class)
click to toggle source
# File lib/object_attorney.rb, line 8 def self.included(base_class) base_class.extend ClassMethods base_class.extend ActiveModel::Validations::HelperMethods end
Public Instance Methods
defendant()
click to toggle source
# File lib/object_attorney.rb, line 13 def defendant @defendant ||= if parent_defendant Helpers.extend_errors_if_necessary(parent_defendant) Helpers.call_method!(parent_defendant, defendant_options[:name]) else Helpers.call_method!(self, defendant_options[:name]) end end
defendant_is_innocent?()
click to toggle source
# File lib/object_attorney.rb, line 24 def defendant_is_innocent? raise Errors::NoDefendantToDefendError if defendant_options.empty? proven_innocent = [defendant].flatten.compact.map do |defendant| innocent_of_all_accusations?(defendant) end.all? make_the_parent_guilty unless proven_innocent proven_innocent end
Also aliased as: valid?
invalid?()
click to toggle source
# File lib/object_attorney.rb, line 38 def invalid? !valid? end
unless_condition_true()
click to toggle source
# File lib/object_attorney/accusation.rb, line 30 def unless_condition_true return nil if options[:unless].nil? !Helpers.call_proc_or_method(@attorney, options[:unless], @defendant) end