module Broi::Input::Soft

Public Class Methods

[](klass) click to toggle source
# File lib/broi/input/soft.rb, line 29
def [](klass)
  register[klass]
end
call(input_class, attrs, errors) click to toggle source
# File lib/broi/input/soft.rb, line 42
def self.call(input_class, attrs, errors)
  attrs = input_class.input[attrs]
  input = Utils.deep_merge(attrs, errors) do |target, _error|
    InvalidValue.new(target)
  end
  input = Utils.deep_transform_values(input) do |value|
    value.is_a?(InvalidValue) ? value : Value.new(value)
  end
  self[input_class].new(input)
end

Private Class Methods

register() click to toggle source
# File lib/broi/input/soft.rb, line 35
def register
  @register ||= Hash.new do |hash, klass|
    hash[klass] = Class.new(klass).include(SoftInput)
  end
end