class ActiveInteraction::HashInput

Represents a processed hash input.

Attributes

children[R]

@overload children

Child inputs if nested filters are used.

@return [Hash{ Symbol => Input, ArrayInput, HashInput }]

Public Class Methods

new(filter, value: nil, error: nil, children: {}) click to toggle source

@private

Calls superclass method
# File lib/active_interaction/hash_input.rb, line 7
def initialize(filter, value: nil, error: nil, children: {})
  super(filter, value: value, error: error)

  @children = children
end

Public Instance Methods

errors() click to toggle source

Any errors that occurred during processing.

@return [Filter::Error]

Calls superclass method
# File lib/active_interaction/hash_input.rb, line 22
def errors
  return @errors if defined?(@errors)

  return @errors = super if @error

  child_errors = get_errors(children)

  return @errors = super if child_errors.empty?

  @errors ||=
    child_errors.map do |error|
      Filter::Error.new(error.filter, error.type, name: :"#{@filter.name}.#{error.name}")
    end.freeze
end

Private Instance Methods

get_errors(children) click to toggle source
# File lib/active_interaction/hash_input.rb, line 39
def get_errors(children)
  children.values.flat_map(&:errors)
end