Class: ActiveInteraction::HashInput

Inherits:
Input
  • Object
show all
Defined in:
lib/active_interaction/hash_input.rb

Overview

Represents a processed hash input.

Instance Attribute Summary collapse

Attributes inherited from Input

#value

Instance Method Summary collapse

Constructor Details

#initialize(filter, value: nil, error: nil, children: {}) ⇒ HashInput

Returns a new instance of HashInput.



7
8
9
10
11
# 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

Instance Attribute Details

#childrenHash{ Symbol => Input, ArrayInput, HashInput } (readonly)

Child inputs if nested filters are used.

Returns:



17
18
19
# File 'lib/active_interaction/hash_input.rb', line 17

def children
  @children
end

Instance Method Details

#errorsFilter::Error

Any errors that occurred during processing.

Returns:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 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