Class: Monolens::ErrorHandler

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/monolens/error_handler.rb

Instance Method Summary collapse

Constructor Details

#initializeErrorHandler

Returns a new instance of ErrorHandler.



5
6
7
# File 'lib/monolens/error_handler.rb', line 5

def initialize
  @errors = []
end

Instance Method Details

#call(error) ⇒ Object



9
10
11
# File 'lib/monolens/error_handler.rb', line 9

def call(error)
  @errors << error
end

#each(&bl) ⇒ Object



13
14
15
# File 'lib/monolens/error_handler.rb', line 13

def each(&bl)
  @errors.each(&bl)
end

#empty?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/monolens/error_handler.rb', line 21

def empty?
  @errors.empty?
end

#reportObject



25
26
27
28
29
# File 'lib/monolens/error_handler.rb', line 25

def report
  @errors
    .map{|err| "[#{err.location.join('/')}] #{err.message}" }
    .join("\n")
end

#sizeObject



17
18
19
# File 'lib/monolens/error_handler.rb', line 17

def size
  @errors.size
end