Sha256: 53f92030ebe69a5f027e95cfa3e9fbc7a07cd333ca60718be7f906726e8d6fd6

Contents?: true

Size: 636 Bytes

Versions: 4

Compression:

Stored size: 636 Bytes

Contents

# frozen_string_literal: true

using SmartCore::Ext::BasicObjectAsObject

# @api public
# @since 0.6.0
SmartCore::Types::Variadic.define_type(:ArrayOf) do |type|
  type.define_caster { |value| SmartCore::Types::Value::Array.cast(value) }

  type.runtime_attributes_checker do |runtime_attrs|
    runtime_attrs.any? && runtime_attrs.all? do |runtime_attr|
      runtime_attr.is_a?(::Class)
    end
  end

  type.define_checker do |value, expected_types|
    next false unless SmartCore::Types::Value::Array.valid?(value)

    value.all? do |elem|
      expected_types.any? { |expected_type| elem.is_a?(expected_type) }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
smart_types-0.8.0 lib/smart_core/types/variadic/array_of.rb
smart_types-0.7.1 lib/smart_core/types/variadic/array_of.rb
smart_types-0.7.0 lib/smart_core/types/variadic/array_of.rb
smart_types-0.6.0 lib/smart_core/types/variadic/array_of.rb