class SoberSwag::Reporting::Input::Mapped

Apply a mapping function over an input.

Attributes

input[R]

@return [Base] base input

mapper[R]

@return [#call] mapping function

Public Class Methods

new(input, mapper) click to toggle source

@param mapper [#call] the mapping function @param input [Base] the base input

# File lib/sober_swag/reporting/input/mapped.rb, line 10
def initialize(input, mapper)
  @mapper = mapper
  @input = input
end

Public Instance Methods

call(value) click to toggle source
# File lib/sober_swag/reporting/input/mapped.rb, line 22
def call(value)
  val = input.call(value)

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

  mapper.call(val)
end
swagger_schema() click to toggle source
# File lib/sober_swag/reporting/input/mapped.rb, line 30
def swagger_schema
  input.swagger_schema
end