Sha256: d615b1d842e06cff210a0d4c2ce4bd00c23a6d461c33922b068a563a86f51962
Contents?: true
Size: 760 Bytes
Versions: 1
Compression:
Stored size: 760 Bytes
Contents
# frozen_string_literal: true module Lite module Command class AttributeValidator attr_reader :command def initialize(command) @command = command end def attributes @attributes ||= command.class.attributes.map do |method_name, options| Lite::Command::Attribute.new(command, method_name, options) end end def errors @errors ||= attributes.each_with_object({}) do |attribute, h| attribute.validate! next if attribute.valid? h[attribute.from] ||= [] h[attribute.from] = h[attribute.from] | attribute.errors end end def valid? attributes.empty? || errors.empty? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lite-command-2.1.0 | lib/lite/command/attribute_validator.rb |