Module: DestinationErrors

Defined in:
lib/destination_errors.rb,
lib/destination_errors/version.rb

Defined Under Namespace

Modules: ClassMethods, Initializer

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/destination_errors.rb', line 36

def self.included(base)
  base.include(ActiveModel::Validations)
  base.prepend(Initializer)
  base.extend(ClassMethods)
  base.class_eval do
    attr_reader :errors
    attr_accessor :errors_finalized
    attr_accessor :surface_errors_on
    class_attribute :error_surfaces
  end
end

Instance Method Details

#error_surfaces_clean?Boolean

Checks to see if any errors have been registered on any of the error surfaces but:

1. does not re-run validations
2. does not add or move errors

returns true if any errors are found on any surface or false otherwise

Returns:

  • (Boolean)


60
61
62
63
64
65
66
67
# File 'lib/destination_errors.rb', line 60

def error_surfaces_clean?
  return false if self.errors.any?
  self.class.error_surfaces.compact.each do |surface|
    return false if errors_on_surface?(surface)
  end
  return false if custom_error_destination_has_errors?
  return true
end

#read_attribute_for_validation(attr) ⇒ Object

Required for ActiveModel::Validations



70
71
72
# File 'lib/destination_errors.rb', line 70

def read_attribute_for_validation(attr)
  send(attr)
end