Class: Eco::API::Common::Loaders::ErrorHandler
- Defined in:
- lib/eco/api/common/loaders/error_handler.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.error(value = nil) ⇒ Eco::API::Error
The error class, child of
Eco::API::Error
.
Instance Method Summary collapse
- #error ⇒ Object
-
#initialize(handlers) ⇒ ErrorHandler
constructor
A new instance of ErrorHandler.
- #main(people, session, options, handler, job) ⇒ Object
Methods inherited from CaseBase
Methods inherited from Base
<=>, created_at, #name, set_created_at!
Methods included from ClassHelpers
#class_resolver, #descendants, #descendants?, #inheritable_attrs, #inheritable_class_vars, #inherited, #instance_variable_name, #new_class, #resolve_class, #to_constant
Constructor Details
#initialize(handlers) ⇒ ErrorHandler
Returns a new instance of ErrorHandler.
21 22 23 24 |
# File 'lib/eco/api/common/loaders/error_handler.rb', line 21 def initialize(handlers) raise "Expected Eco::API::Policies. Given #{handlers.class}" unless handlers.is_a?(Eco::API::Error::Handlers) handlers.on(self.error, &self.method(:main)) end |
Class Attribute Details
.error(value = nil) ⇒ Eco::API::Error
Returns the error class, child of Eco::API::Error
.
11 12 13 14 15 16 |
# File 'lib/eco/api/common/loaders/error_handler.rb', line 11 def error(value = nil) unless value return @error || raise("You should specify an error type for #{self.class}") end @error = value end |
Instance Method Details
#error ⇒ Object
35 36 37 |
# File 'lib/eco/api/common/loaders/error_handler.rb', line 35 def error self.class.error end |
#main(people, session, options, handler, job) ⇒ Object
31 32 33 |
# File 'lib/eco/api/common/loaders/error_handler.rb', line 31 def main(people, session, , handler, job) raise "You should implement this method" end |