module Metasploit::Model::Search::With::ClassMethods

Defines `search_with` DSL, which is a lower-level way than search_attribute to add operators. `search_with` allows instance of arbitrary operator_classes to be registered in {#search_with_operator_by_name}.

Public Instance Methods

search_with(operator_class, options={}) click to toggle source

Declares that this class should be search with an instance of the given `operator_class`.

@param operator_class [Class<Metasploit::Model::Search::Operator::Base>] a class to initialize. @param options [Hash] Options passed to `operator_class.new` along with `{:klass => self}`, so that the

`operator_class` instance knows it was registered as search this class.

@return [Metasploit::Model::Search::Operator::Base] @raise (see Metasploit::Model::Base#invalid!)

# File lib/metasploit/model/search/with.rb, line 58
def search_with(operator_class, options={})
  merged_operations = options.merge(
      :klass => self
  )
  operator = operator_class.new(merged_operations)
  operator.valid!

  search_with_operator_by_name[operator.name] = operator
end
search_with_operator_by_name() click to toggle source

Operators registered with {#search_with}.

@return [Hash{Symbol => Metasploit::Model::Search::Operator::Base}] Maps

{Metasploit::Model::Search::Operator::Base#name} keys to {Metasploit::Model::Search::Operator::Base#name}
values.
# File lib/metasploit/model/search/with.rb, line 73
def search_with_operator_by_name
  @search_with_operator_by_name ||= {}
end