Sha256: 200674c9a933a527742bdc369a8495990f12fed04b64a4c4a9b9eaa4c5467268
Contents?: true
Size: 694 Bytes
Versions: 3
Compression:
Stored size: 694 Bytes
Contents
module DataModel # A simple abstraction to handle test data class Fixtures::Example # @param schema [Array] the schema # @param variants [Hash{Symbol => untyped}] the variants used by each example # @return [Schema] the schema def initialize(schema, variants:) @schema = schema @variants = variants end # @return [Model] the model def model DataModel.define(@schema) end # @param type [Symbol] the variant to use # @return [Array(Model, untyped)] a tuple of [model, variant] def [](type) if !@variants.key?(type) raise "#{type} is not a defined variant: #{@variants}" end result = @variants.fetch(type) return [model, result] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
data_model-0.6.1 | lib/data_model/fixtures/example.rb |
data_model-0.6.0 | lib/data_model/fixtures/example.rb |
data_model-0.5.0 | lib/data_model/fixtures/example.rb |