Class: Fixtures::Example
- Inherits:
-
Object
- Object
- Fixtures::Example
- Defined in:
- lib/data_model/fixtures/example.rb
Overview
A simple abstraction to handle test data
Instance Method Summary collapse
-
#[](type) ⇒ Array(Model, untyped)
A tuple of [model, variant].
-
#initialize(schema, variants:) ⇒ Schema
constructor
The schema.
-
#model ⇒ Model
The model.
Constructor Details
#initialize(schema, variants:) ⇒ Schema
Returns the schema.
7 8 9 10 |
# File 'lib/data_model/fixtures/example.rb', line 7 def initialize(schema, variants:) @schema = schema @variants = variants end |
Instance Method Details
#[](type) ⇒ Array(Model, untyped)
Returns a tuple of [model, variant].
19 20 21 22 23 24 25 26 27 |
# File 'lib/data_model/fixtures/example.rb', line 19 def [](type) if !@variants.key?(type) raise "#{type} is not a defined variant: #{@variants}" end result = @variants.fetch(type) return [model, result] end |