Sha256: d9f54c4e780b01420b14f605fb7502664eddcea0b4df12df4b8294ace52e8a07
Contents?: true
Size: 1.32 KB
Versions: 4
Compression:
Stored size: 1.32 KB
Contents
# typed: strict module DataModel module Fixtures::Hash include Fixtures extend T::Sig extend self TContact = T.type_alias { T::Hash[Symbol, T.untyped] } sig { returns(TContact) } def example_contact { first_name: "foo", last_name: "bar", email: "foo@bar.com" } end sig { returns(Example) } def contact Example.new( [:hash, [:first_name, :string], [:last_name, :string, { optional: true }], [:email, :string]], variants: { valid: example_contact, missing: nil, coercible: example_contact.to_a, missing_email: example_contact.tap { |h| T.cast(h, TContact).delete(:email) }, invalid_field: example_contact.merge(email: 123), other_type: [] }, ) end sig { returns(Example) } def optional_contact Example.new( [:hash, { optional: true }, [:first_name, :string], [:last_name, :string, { optional: true }], [:email, :string]], variants: { valid: example_contact, missing: nil }, ) end sig { returns(Example) } def closed_contact Example.new( [:hash, { open: false }, [:first_name, :string], [:last_name, :string, { optional: true }], [:email, :string]], variants: { valid: example_contact, extra_keys: example_contact.merge(extra: "keys") }, ) end end end
Version data entries
4 entries across 4 versions & 1 rubygems