Class: Metasploit::Model::Search::Operator::Base

Inherits:
Base
  • Object
show all
Includes:
ActiveModel::Validations, Help
Defined in:
app/models/metasploit/model/search/operator/base.rb

Overview

Instead of writing an operator completely from scratch, you can subclass Base.

class MyOperator < Metasploit::Model::Search::Operator::Base
  # Name of this operator.  The name of the operator is matched to the string before the ':' in a formatted
  # operation.
  #
  # @return [Symbol]
  def name
    # ...
  end

  # Creates a one or more operations based on `formatted_value`.
  #
  # @return [#operator, Array<#operator>] Operation with this operator as the operation's `operator`.
  def operate_on(formatted_value)
    # ...
  end
end

Direct Known Subclasses

Association, Delegation, Single

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Help

#help

Methods inherited from Base

#initialize, #valid!

Constructor Details

This class inherits a constructor from Metasploit::Model::Base

Instance Attribute Details

#klassClass

The class on which this operator is usable.

Returns:

  • (Class)

33
34
35
# File 'app/models/metasploit/model/search/operator/base.rb', line 33

def klass
  @klass
end

Instance Method Details

#nameString

This method is abstract.

subclass and derive operator name from attributes of subclass.

Name of this operator.

Returns:

  • (String)

Raises:

  • (NotImplementedError)

47
48
49
# File 'app/models/metasploit/model/search/operator/base.rb', line 47

def name
  raise NotImplementedError
end