lib/data_model/fixtures/array.rb in data_model-0.4.0 vs lib/data_model/fixtures/array.rb in data_model-0.5.0
- old
+ new
@@ -1,54 +1,67 @@
-# typed: strict
-
module DataModel
+ # test fixtures for array type
module Fixtures::Array
extend self
- extend T::Sig
include Fixtures
- sig { returns(Example) }
+ # 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
+ other_type: ::Object.new
},
)
end
- sig { returns(Example) }
+ # 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
+ other_type: ::Object.new
},
)
end
- sig { returns(Example) }
+ # 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
- sig { returns(Example) }
+ # 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"],