Sha256: 57c63c461697c736958260e095ab3abc860c4e65d52828236dc6cabf7c35c693

Contents?: true

Size: 751 Bytes

Versions: 7

Compression:

Stored size: 751 Bytes

Contents

module SoberSwag
  module Reporting
    module Input
      ##
      # Apply a mapping function over an input.
      class Mapped < Base
        ##
        # @param mapper [#call] the mapping function
        # @param input [Base] the base input
        def initialize(input, mapper)
          @mapper = mapper
          @input = input
        end

        ##
        # @return [#call] mapping function
        attr_reader :mapper
        ##
        # @return [Base] base input
        attr_reader :input

        def call(value)
          val = input.call(value)

          return val if val.is_a?(Report::Base)

          mapper.call(val)
        end

        def swagger_schema
          input.swagger_schema
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sober_swag-0.25.2 lib/sober_swag/reporting/input/mapped.rb
sober_swag-0.25.1 lib/sober_swag/reporting/input/mapped.rb
sober_swag-0.25.0 lib/sober_swag/reporting/input/mapped.rb
sober_swag-0.24.1 lib/sober_swag/reporting/input/mapped.rb
sober_swag-0.24.0 lib/sober_swag/reporting/input/mapped.rb
sober_swag-0.23.0 lib/sober_swag/reporting/input/mapped.rb
sober_swag-0.22.0 lib/sober_swag/reporting/input/mapped.rb