Class: HumanistErrors::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/humanist_errors/search.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_object, ruby_error_message) ⇒ Search

Returns a new instance of Search.



12
13
14
15
# File 'lib/humanist_errors/search.rb', line 12

def initialize(error_object, ruby_error_message)
  @error_object = error_object
  @ruby_error_message = ruby_error_message
end

Instance Attribute Details

#error_objectObject

Returns the value of attribute error_object.



4
5
6
# File 'lib/humanist_errors/search.rb', line 4

def error_object
  @error_object
end

#found_errorObject

Returns the value of attribute found_error.



3
4
5
# File 'lib/humanist_errors/search.rb', line 3

def found_error
  @found_error
end

#ruby_error_messageObject

Returns the value of attribute ruby_error_message.



4
5
6
# File 'lib/humanist_errors/search.rb', line 4

def ruby_error_message
  @ruby_error_message
end

Class Method Details

.run(error_object, ruby_error_message) ⇒ Object



6
7
8
9
10
# File 'lib/humanist_errors/search.rb', line 6

def self.run(error_object, ruby_error_message)
  searcher = new(error_object, ruby_error_message)
  searcher.found_error = searcher.find
  searcher
end

Instance Method Details

#findObject



17
18
19
20
21
# File 'lib/humanist_errors/search.rb', line 17

def find
  error = keyify(error_object)
  return :no_result unless ERROR_MAPPER.keys.include?(error)
  ERROR_MAPPER[error][ruby_error_message]
end