Class: ActiveInteractor::Type::List

Inherits:
Base
  • Object
show all
Defined in:
lib/active_interactor/type/list.rb

Instance Method Summary collapse

Methods inherited from Base

valid?

Constructor Details

#initialize(type) ⇒ List

rubocop:disable Lint/MissingSuper



6
7
8
# File 'lib/active_interactor/type/list.rb', line 6

def initialize(type) # rubocop:disable Lint/MissingSuper
  @type = type
end

Instance Method Details

#valid?(value) ⇒ Boolean

Returns:



10
11
12
13
14
15
16
# File 'lib/active_interactor/type/list.rb', line 10

def valid?(value)
  return false unless value.is_a?(Array)

  value.all? do |element|
    element.nil? || element.is_a?(@type) || (@type.is_a?(ActiveInteractor::Type::Base) && @type.valid?(element))
  end
end