Sha256: f9847e6b0a273d81fc5b432a83fc5a22930101ce71d599cc1313d478e430fb06

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module BloodContracts
  class Suite
    extend Dry::Initializer

    option :contract, ->(v) { Hashie::Mash.new(v) }
    option :data_generator, optional: true

    option :input_writer,  optional: true
    option :output_writer, optional: true

    option :input_serializer,  optional: true
    option :output_serializer, optional: true
    option :meta_serializer, optional: true

    option :storage_backend, optional: true
    option :storage, default: -> { default_storage }

    def data_generator=(generator)
      raise ArgumentError unless generator.respond_to?(:call)
      @data_generator = generator
    end

    def input_writer=(writer)
      storage.input_writer = writer
    end

    def output_writer=(writer)
      storage.output_writer = writer
    end

    def default_storage
      Storage.new(
        input_writer:  input_writer,
        output_writer: output_writer,
        input_serializer:  input_serializer,
        output_serializer: output_serializer,
        meta_serializer:   meta_serializer,
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blood_contracts-0.2.1 lib/blood_contracts/suite.rb