module DataModel # test fixtures for array type module Fixtures::Array extend self include Fixtures # a simple array of any types # @return [Example] the example def any_array Example.new( [:array], variants: { mixed: ["a", 2, [], ::Object.new] }, ) end # a simple array of strings example # @return [Example] the example def string_array Example.new( [:array, :string], variants: { strings: ["a", "b", "c"], string: ["a", ["a"]], number: [1, ["1"]], missing: nil, numbers: [[1, 2, 3], ["1", "2", "3"]], other_type: ::Object.new }, ) end # a simple array of strings that wraps single values # @return [Example] the example def wrapping_string_array Example.new( [:array, { wrap_single_value: true }, :string], variants: { strings: ["a", "b", "c"], string: ["a", ["a"]], number: [1, ["1"]], missing: nil, numbers: [[1, 2, 3], ["1", "2", "3"]], other_type: ::Object.new }, ) end # an optional example # @return [Example] the example def optional_string_array Example.new( [:array, { optional: true }, :string], variants: { strings: ["a", "b", "c"], missing: nil }, ) end # an array of optional strings # @return [Example] the example def array_optional_string Example.new( [:array, [:string, { optional: true }]], variants: { optional_strings: ["a", nil, "c"], numbers: [1, nil, 3] }, ) end end end