Module: ActiveModel::BetterErrors

Defined in:
lib/active_model/better_errors.rb,
lib/active_model/better_errors/errors.rb,
lib/active_model/better_errors/version.rb,
lib/active_model/better_errors/reporter.rb,
lib/active_model/better_errors/emulation.rb,
lib/active_model/better_errors/formatter.rb,
lib/active_model/better_errors/error_message.rb,
lib/active_model/better_errors/hash_reporter.rb,
lib/active_model/better_errors/array_reporter.rb,
lib/active_model/better_errors/error_collection.rb,
lib/active_model/better_errors/message_reporter.rb,
lib/active_model/better_errors/error_message_set.rb,
lib/active_model/better_errors/human_hash_reporter.rb,
lib/active_model/better_errors/human_array_reporter.rb,
lib/active_model/better_errors/machine_hash_reporter.rb,
lib/active_model/better_errors/human_message_reporter.rb,
lib/active_model/better_errors/machine_array_reporter.rb,
lib/active_model/better_errors/human_message_formatter.rb

Overview

BetterErrors

Defined Under Namespace

Modules: Emulation Classes: ArrayReporter, ErrorCollection, ErrorMessage, ErrorMessageSet, Errors, Formatter, HashReporter, HumanArrayReporter, HumanHashReporter, HumanMessageFormatter, HumanMessageReporter, MachineArrayReporter, MachineHashReporter, MessageReporter, Reporter

Constant Summary collapse

VERSION =
'1.6.7'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.formatterObject

Returns the value of attribute formatter.



35
36
37
# File 'lib/active_model/better_errors.rb', line 35

def formatter
  @formatter
end

Class Method Details

.format_message(base, message) ⇒ Object



55
56
57
# File 'lib/active_model/better_errors.rb', line 55

def format_message(base, message)
  formatter.new(base, message).format_message
end

.get_reporter_class(name, reporter) ⇒ Object



49
50
51
52
53
# File 'lib/active_model/better_errors.rb', line 49

def get_reporter_class(name, reporter)
  return reporter if reporter.is_a? Class
  class_name = "#{reporter}_#{name}_reporter"
  "active_model/better_errors/#{class_name}".classify.constantize
end

.reportersObject



44
45
46
47
# File 'lib/active_model/better_errors.rb', line 44

def reporters
  @reporter_maps ||= {}
  @reporter_maps.clone
end

.set_reporter(name, reporter) ⇒ Object



37
38
39
40
41
42
# File 'lib/active_model/better_errors.rb', line 37

def set_reporter(name, reporter)
  name = name.to_s
  @reporter_maps ||= {}
  return @reporter_maps.delete(name) unless reporter
  @reporter_maps[name] = get_reporter_class(name, reporter)
end