Sha256: 0d1494cc77c25159483aaf42cab668e9d8acfcc53af7fbb62d5bc137f9b93d18

Contents?: true

Size: 1.46 KB

Versions: 13

Compression:

Stored size: 1.46 KB

Contents

module Eco
  module API
    module Common
      module Loaders
        class ErrorHandler < Eco::API::Common::BaseLoader

          class << self
            attr_writer :error

            # @return [Eco::API::Error] the error class, child of `Eco::API::Error`.
            def error(value = nil)
              unless value
                return @error || raise("You should specify an error type for #{self.class}")
              end
              @error = value
            end
          end

          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

          # @param people [Eco::API::Organization::People] the people in the queue of the current `job`
          # @param session [Eco::API::Session] the current session where the usecase kicks in.
          # @param options [Hash] the options that modify the case behaviour or bring some dependencies.
          # @param handler [Eco::API::Error::Hanlder] the `error handler` instance object.
          # @param job [Eco::API::Session::Batch::Job] the `Batch::Job` made on purpose for this handler.
          def main(people, session, options, handler, job)
            raise "You should implement this method"
          end

          def error
            self.class.error
          end

        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
eco-helpers-1.5.14 lib/eco/api/common/loaders/error_handler.rb
eco-helpers-1.5.13 lib/eco/api/common/loaders/error_handler.rb
eco-helpers-1.5.12 lib/eco/api/common/loaders/error_handler.rb
eco-helpers-1.5.11 lib/eco/api/common/loaders/error_handler.rb
eco-helpers-1.5.10 lib/eco/api/common/loaders/error_handler.rb
eco-helpers-1.5.9 lib/eco/api/common/loaders/error_handler.rb
eco-helpers-1.5.8 lib/eco/api/common/loaders/error_handler.rb
eco-helpers-1.5.7 lib/eco/api/common/loaders/error_handler.rb
eco-helpers-1.5.6 lib/eco/api/common/loaders/error_handler.rb
eco-helpers-1.5.5 lib/eco/api/common/loaders/error_handler.rb
eco-helpers-1.5.4 lib/eco/api/common/loaders/error_handler.rb
eco-helpers-1.5.3 lib/eco/api/common/loaders/error_handler.rb
eco-helpers-1.5.2 lib/eco/api/common/loaders/error_handler.rb