Class: Sevgi::ValidationError
- Inherits:
-
Error
- Object
- Error
- Sevgi::ValidationError
- Defined in:
- lib/sevgi/standard/errors.rb
Overview
Base class for SVG standard validation errors.
Class Method Summary collapse
-
.call(context, args = []) ⇒ void
Raises this validation error class.
-
.variant(message) ⇒ Class<Sevgi::ValidationError>
Builds a validation error subclass with a fixed message fragment.
Instance Method Summary collapse
-
#initialize(context, args = []) ⇒ void
constructor
Builds a validation error with a context label and offending values.
Constructor Details
#initialize(context, args = []) ⇒ void
Builds a validation error with a context label and offending values.
10 11 12 13 14 15 |
# File 'lib/sevgi/standard/errors.rb', line 10 def initialize(context, args = []) @context = context @args = Array(args) super() end |
Class Method Details
.call(context, args = []) ⇒ void
This method returns an undefined value.
Raises this validation error class.
22 23 24 |
# File 'lib/sevgi/standard/errors.rb', line 22 def self.call(context, args = []) raise new(context, args) end |
.variant(message) ⇒ Class<Sevgi::ValidationError>
Builds a validation error subclass with a fixed message fragment.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sevgi/standard/errors.rb', line 29 def self.variant() Class.new(self) do define_method(:message) do [@context, ] .tap do || << @args.map { "'#{it}'" }.join(", ") unless @args.empty? end .join(": ") end end end |