Module: Fixtures::Hash
- Extended by:
- Hash, T::Sig
- Includes:
- Fixtures
- Included in:
- Hash
- Defined in:
- lib/data_model/fixtures/hash.rb
Constant Summary collapse
- TContact =
T.type_alias { T::Hash[Symbol, T.untyped] }
Instance Method Summary collapse
Instance Method Details
#closed_contact ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/data_model/fixtures/hash.rb', line 53 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 |
#contact ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/data_model/fixtures/hash.rb', line 21 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 |
#example_contact ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/data_model/fixtures/hash.rb', line 12 def example_contact { first_name: "foo", last_name: "bar", email: "[email protected]" } end |
#optional_contact ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/data_model/fixtures/hash.rb', line 39 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 |