class ScrivenerErrors
Constants
- MESSAGES
Attributes
scrivener[R]
Public Class Methods
new(scrivener)
click to toggle source
# File lib/scrivener_errors.rb, line 14 def initialize(scrivener) @scrivener = scrivener ensure_validated end
Public Instance Methods
[](att)
click to toggle source
# File lib/scrivener_errors.rb, line 25 def [](att) errors = scrivener.errors[att.to_sym] if errors.length > 0 errors.map { |e| lookup(e) }.join(', ') end end
ensure_validated()
click to toggle source
# File lib/scrivener_errors.rb, line 19 def ensure_validated if scrivener.errors == {} scrivener.valid? end end
error_string(att, error)
click to toggle source
# File lib/scrivener_errors.rb, line 45 def error_string(att, error) att = att.to_s.tr('_', ' ') [att, lookup(error)].join(' ') end
lookup(key)
click to toggle source
# File lib/scrivener_errors.rb, line 50 def lookup(key) MESSAGES.fetch(key, 'is invalid') end
message()
click to toggle source
# File lib/scrivener_errors.rb, line 33 def message messages.join(', ').capitalize end
Also aliased as: to_s
messages()
click to toggle source
# File lib/scrivener_errors.rb, line 38 def messages scrivener.errors.each_with_object([]) do |error, collection| att = error[0] collection.concat error[1].map {|e| error_string(att, e) } end end