Class: Apicraft::Mocker::Array

Inherits:
Base
  • Object
show all
Defined in:
lib/apicraft/mocker/array.rb

Overview

Generate an array based on the schema using Mocker types

Instance Attribute Summary

Attributes inherited from Base

#schema

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Apicraft::Mocker::Base

Instance Method Details

#mockObject



8
9
10
11
12
13
14
15
16
# File 'lib/apicraft/mocker/array.rb', line 8

def mock
  ::Array.new(
    (min_items..max_items)
    .to_a
    .sample
  ).map do |_i|
    Mocker.mock(schema.items)
  end
end