Class: Arachni::RPC::Message
Overview
Instance Method Summary (collapse)
-
- (Message) initialize(opts = {})
constructor
A new instance of Message.
-
- (Object) merge!(message)
Merges the attributes of another message with self.
-
- (Hash) prepare_for_tx
Prepares the message for transmission (i.e. converts the message to a Hash).
-
- (Boolean) transmit?(attr)
Decides which attributes should be skipped by #prepare_for_tx.
Constructor Details
- (Message) initialize(opts = {})
A new instance of Message
22 23 24 |
# File 'lib/arachni/rpc/message.rb', line 22 def initialize( opts = {} ) opts.each_pair { |k, v| instance_variable_set( "@#{k}".to_sym, v ) } end |
Instance Method Details
- (Object) merge!(message)
Merges the attributes of another message with self.
(The param doesn't really have to be a message, any object will do.)
33 34 35 36 37 38 |
# File 'lib/arachni/rpc/message.rb', line 33 def merge!( ) .instance_variables.each do |var| val = .instance_variable_get( var ) instance_variable_set( var, val ) end end |
- (Hash) prepare_for_tx
Prepares the message for transmission (i.e. converts the message to a Hash).
Attributes that should not be included can be skipped by implementing #transmit? and returning the appropriate value.
48 49 50 51 52 53 |
# File 'lib/arachni/rpc/message.rb', line 48 def prepare_for_tx instance_variables.inject({}) do |h, k| h[normalize( k )] = instance_variable_get( k ) if transmit?( k ) h end end |
- (Boolean) transmit?(attr)
Decides which attributes should be skipped by #prepare_for_tx.
60 61 62 |
# File 'lib/arachni/rpc/message.rb', line 60 def transmit?( attr ) true end |