Sha256: 02670d273a12208c2a6e2fcea486df40197259d5dd306397fa20b6e365237471
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
module NxtSchema module Application class ErrorStore < ::Hash def initialize(application) super() @application = application end attr_reader :application def add_schema_error(message:) add_error( application, NxtSchema::Application::Errors::SchemaError.new( application: application, message: message ) ) end def add_validation_error(message:) add_error( application, NxtSchema::Application::Errors::ValidationError.new( application: application, message: message ) ) end def merge_errors(application) merge!(application.errors) end def add_error(application, error) self[application.error_key] ||= [] self[application.error_key] << error end # def schema_errors # inject({}) do |acc, (k, v)| # errors = v.select { |e| e.is_a?(NxtSchema::Application::Errors::SchemaError) } # acc[k] = errors if errors.any? # acc # end # end # # def validation_errors # inject({}) do |acc, (k, v)| # errors = v.select { |e| e.is_a?(NxtSchema::Application::Errors::ValidationError) } # acc[k] = errors if errors.any? # acc # end # end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nxt_schema-1.0.0 | lib/nxt_schema/application/error_store.rb |