Sha256: 1ddc464b6db44d930aa5386041e5767be2ceb2d815052a44f2e982f48e7b8a4e
Contents?: true
Size: 732 Bytes
Versions: 3
Compression:
Stored size: 732 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, attribute| attribute.tap { |a| a.command = command } end end def errors @errors ||= attributes.each_with_object({}) do |attribute, h| next if attribute.tap(&:validate!).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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lite-command-2.1.3 | lib/lite/command/attribute_validator.rb |
lite-command-2.1.2 | lib/lite/command/attribute_validator.rb |
lite-command-2.1.1 | lib/lite/command/attribute_validator.rb |