module SoberSwag::Reporting::Output::Interface
Interface
methods for all outputs.
Public Instance Methods
array()
click to toggle source
# File lib/sober_swag/reporting/output/interface.rb, line 79 def array List.new(self) end
call!(item)
click to toggle source
# File lib/sober_swag/reporting/output/interface.rb, line 7 def call!(item) res = serialize_report(item) raise Report::Error.new(res) if res.is_a?(Report::Base) # rubocop:disable Style/RaiseArgs res end
described(description)
click to toggle source
# File lib/sober_swag/reporting/output/interface.rb, line 83 def described(description) Described.new(self, description) end
enum(*cases)
click to toggle source
@return [SoberSwag::Reporting::Output::Enum]
# File lib/sober_swag/reporting/output/interface.rb, line 35 def enum(*cases) Enum.new(self, cases) end
list()
click to toggle source
# File lib/sober_swag/reporting/output/interface.rb, line 43 def list List.new(self) end
nilable()
click to toggle source
# File lib/sober_swag/reporting/output/interface.rb, line 71 def nilable Partitioned.new( :nil?.to_proc, Null.new, self ) end
partitioned(other, &block)
click to toggle source
Partition this serializer into two potentials. If the block given returns false, we will use `other` as the serializer. Otherwise, we will use `self`.
This might be useful to serialize a sum type:
“`ruby ResolutionOutput = TransferOutput.partitioned(RefundOutput) { |to_serialize| to_serialize.is_a?(Transfer) “`
@param other [Interface] serializer to use if the block returns false @yieldreturn [true,false] false if we should use the other serializer @return [Interface]
# File lib/sober_swag/reporting/output/interface.rb, line 61 def partitioned(other, &block) raise ArgumentError, 'need a block' if block.nil? Partitioned.new( block, self, other ) end
referenced(name)
click to toggle source
# File lib/sober_swag/reporting/output/interface.rb, line 39 def referenced(name) Referenced.new(self, name) end
reporting?()
click to toggle source
Show off that this is a reporting output.
# File lib/sober_swag/reporting/output/interface.rb, line 17 def reporting? true end
serialize(item)
click to toggle source
Delegates to {#call}
# File lib/sober_swag/reporting/output/interface.rb, line 23 def serialize(item) call(item) end
via_map(&block)
click to toggle source
# File lib/sober_swag/reporting/output/interface.rb, line 27 def via_map(&block) raise ArgumentError, 'block argument required' unless block ViaMap.new(self, block) end