module Metasploit::Model::Search::Association::ClassMethods

Adds {#search_association} DSL to make {Metasploit::Model::Search::Operator::Association association search operators}.

Public Instance Methods

search_association(association) click to toggle source

@note Use {#search_associations} to declare multiple associations or a tree of far associations as

searchable.

Registers association for search.

@example a single searchable association

search_association :children

@param association [#to_sym] name of association to search. @return [void] @see search_associations

# File lib/metasploit/model/search/association.rb, line 107
def search_association(association)
  search_association_tree[association.to_sym] ||= nil
end
search_association_operators() click to toggle source

The association operators for the searchable associations declared with {#search_association} and {#search_associations}.

@return (see Metasploit::Model::Association::Tree.operators)

# File lib/metasploit/model/search/association.rb, line 156
def search_association_operators
  @search_association_operators ||= Metasploit::Model::Association::Tree.operators(
      search_association_tree,
      class: self
  )
end
search_association_tree() click to toggle source

Tree of associations that are searchable.

@return [Hash{Symbol => Hash,nil}]

# File lib/metasploit/model/search/association.rb, line 166
def search_association_tree
  @search_association_tree ||= {}
end
search_associations(*associations) click to toggle source

Registers a tree of near and far associations for search. When a tree is used, all intermediate association on the paths are used, so `search_association children: :grandchildren` makes both `children.granchildren` and `children` as search operator prefixes.

@example a single search association

search_associations :children

@example multiple near associations

search_associations :first,
                    :second

@example far association

search_associations near: :far

@example multiple far associations

search_associations near: [
                      :first_far,
                      :second_far
                    ]

@example mix of near and far associations

# Keep associations in order by near association names by mixing Symbols and Hash{Symbol => Object}
search_associations :apple,
                    {
                      banana: :peel
                    },
                    :cucumber

@param associations [Array<Array, Hash, Symbol>, Hash, Symbol] @return [void] @see #search_association

# File lib/metasploit/model/search/association.rb, line 143
def search_associations(*associations)
  expanded_associations = Metasploit::Model::Association::Tree.expand(associations)

  @search_association_tree = Metasploit::Model::Association::Tree.merge(
      search_association_tree,
      expanded_associations
  )
end