Class: SoberSwag::Reporting::Report::Either

Inherits:
Base
  • Object
show all
Defined in:
lib/sober_swag/reporting/report/either.rb

Overview

Models either one set of errors or another. Will enumerate them in order with #each_error

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#full_errors, #path_hash

Constructor Details

#initialize(lhs, rhs) ⇒ Either

Returns a new instance of Either.



8
9
10
11
# File 'lib/sober_swag/reporting/report/either.rb', line 8

def initialize(lhs, rhs)
  @lhs = lhs
  @rhs = rhs
end

Instance Attribute Details

#lhsBase (readonly)

Returns left reports.

Returns:

  • (Base)

    left reports



15
16
17
# File 'lib/sober_swag/reporting/report/either.rb', line 15

def lhs
  @lhs
end

#rhsBase (readonly)

Returns right reports.

Returns:

  • (Base)

    right reports



18
19
20
# File 'lib/sober_swag/reporting/report/either.rb', line 18

def rhs
  @rhs
end

Instance Method Details

#each_errorObject

rubocop:disable Style/ExplicitBlockArgument



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sober_swag/reporting/report/either.rb', line 21

def each_error
  return enum_for(:each_error) unless block_given?

  lhs.each_error do |key, value|
    yield key, value
  end

  rhs.each_error do |key, value|
    yield key, value
  end
end