Class: SoberSwag::Reporting::Input::Mapped
- Defined in:
- lib/sober_swag/reporting/input/mapped.rb
Overview
Apply a mapping function over an input.
Instance Attribute Summary collapse
-
#input ⇒ Base
readonly
Base input.
-
#mapper ⇒ #call
readonly
Mapping function.
Instance Method Summary collapse
- #call(value) ⇒ Object
-
#initialize(input, mapper) ⇒ Mapped
constructor
A new instance of Mapped.
- #swagger_schema ⇒ Object
Methods included from Interface
#add_schema_key, #call!, #described, #enum, #format, #in_range, #list, #mapped, #modify_schema, #multiple_of, #optional, #or, #referenced, #swagger_path_schema, #swagger_query_schema, #|
Constructor Details
#initialize(input, mapper) ⇒ Mapped
Returns a new instance of Mapped.
10 11 12 13 |
# File 'lib/sober_swag/reporting/input/mapped.rb', line 10 def initialize(input, mapper) @mapper = mapper @input = input end |
Instance Attribute Details
#input ⇒ Base (readonly)
Returns base input.
20 21 22 |
# File 'lib/sober_swag/reporting/input/mapped.rb', line 20 def input @input end |
#mapper ⇒ #call (readonly)
Returns mapping function.
17 18 19 |
# File 'lib/sober_swag/reporting/input/mapped.rb', line 17 def mapper @mapper end |
Instance Method Details
#call(value) ⇒ Object
22 23 24 25 26 27 28 |
# 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 ⇒ Object
30 31 32 |
# File 'lib/sober_swag/reporting/input/mapped.rb', line 30 def swagger_schema input.swagger_schema end |