class RaptorIO::Protocol::HTTP::Request::Manipulator
Base manipulator class, all manipulator components should inherit from it.
@author Tasos Laskos <tasos_laskos@rapid7.com> @abstract
Attributes
@return [HTTP::Client] Current HTTP
client instance.
@return [Hash] Manipulator
options.
@return [HTTP::Request] Request
to manipulate.
Public Class Methods
Registers manipulators which inherit from this class.
@see Request::Manipulators#register
# File lib/raptor-io/protocol/http/request/manipulator.rb, line 106 def inherited( manipulator_klass ) Request::Manipulators.register( Request::Manipulators.path_to_name( caller.first.split( ':' ).first ), manipulator_klass ) end
@param [HTTP::Client] client
HTTP client which will handle the request.
@param [HTTP::Request] request
Request to process.
# File lib/raptor-io/protocol/http/request/manipulator.rb, line 42 def initialize( client, request, options = {} ) @client = client @request = request @options = options end
@return [String] Shortname of ‘self`.
# File lib/raptor-io/protocol/http/request/manipulator.rb, line 99 def shortname @shortname ||= Request::Manipulators.class_to_name( self ) end
@return [Hash{Symbol=>Array<String>}]
Option names keys for and error messages for values.
# File lib/raptor-io/protocol/http/request/manipulator.rb, line 81 def validate_options( &block ) fail ArgumentError, 'Missing block.' if !block_given? @validator = block end
@param [Hash] options Manipulator
options. @param [HTTP::Client] client Applicable client.
@return [Hash{Symbol=>Array<String>}]
Option names keys for and error messages for values.
@abstract
# File lib/raptor-io/protocol/http/request/manipulator.rb, line 94 def validate_options!( options, client ) @validator ? @validator.call( options, client ) : {} end
Public Instance Methods
@return [Hash] Persistent storage – per {HTTP::Client} instance.
# File lib/raptor-io/protocol/http/request/manipulator.rb, line 62 def datastore client.datastore[shortname] end
Delegates the work to another manipulator.
@param [Symbol] manipulator Manipulator
to run. @param [Hash] opts Manipulator
options.
# File lib/raptor-io/protocol/http/request/manipulator.rb, line 57 def delegate( manipulator, opts = options ) Request::Manipulators.process( manipulator, client, request, opts ) end
Delivers the manipulator’s payload. @abstract
# File lib/raptor-io/protocol/http/request/manipulator.rb, line 50 def run end
@return [String] Shortname of ‘self`.
# File lib/raptor-io/protocol/http/request/manipulator.rb, line 67 def shortname self.class.shortname end
@return [Hash{Symbol=>Array<String>}]
Option names keys for and error messages for values.
# File lib/raptor-io/protocol/http/request/manipulator.rb, line 73 def validate_options self.class.validate_options!( options, client ) end