Sha256: f39b47bbfc92cda3907723bbc8f7deba29fc455e4d31d06265f31e8110441f16

Contents?: true

Size: 1.21 KB

Versions: 115

Compression:

Stored size: 1.21 KB

Contents

# Gathers all the association names to pass to `ActiveRecord::Relation#includes` from a
# `Metasploit::Model::Search::Query`
class MetasploitDataModels::Search::Visitor::Includes
  include Metasploit::Model::Visitation::Visit

  #
  # Visitors
  #

  visit 'Metasploit::Model::Search::Group::Base',
        'Metasploit::Model::Search::Operation::Group::Base' do |parent|
    parent.children.flat_map { |child|
      visit child
    }
  end

  visit 'Metasploit::Model::Search::Operation::Association' do |operation|
    association = visit operation.operator
    nested_associations = visit operation.source_operation

    if nested_associations.empty?
      [association]
    else
      [
          {
              association => nested_associations
          }
      ]
    end
  end

  visit 'Metasploit::Model::Search::Operation::Base' do |operation|
    visit operation.operator
  end

  visit 'Metasploit::Model::Search::Operator::Association' do |operator|
    operator.association
  end

  visit 'Metasploit::Model::Search::Operator::Attribute',
        'MetasploitDataModels::Search::Operator::IPAddress',
        'MetasploitDataModels::Search::Operator::Port::List' do |_operator|
    []
  end

  Metasploit::Concern.run(self)
end

Version data entries

115 entries across 115 versions & 2 rubygems

Version Path
wg-metasploit_data_models-4.1.4.02 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-6.0.5 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-6.0.4 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-6.0.3 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-6.0.2 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-6.0.1 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-6.0.0 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-5.0.6 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-5.0.5 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-5.0.4 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-5.0.3 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-5.0.2 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-5.0.1 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-5.0.0 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-4.1.4 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-4.1.3 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-4.1.2 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-4.1.1 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-4.1.0 app/models/metasploit_data_models/search/visitor/includes.rb
metasploit_data_models-4.0.2 app/models/metasploit_data_models/search/visitor/includes.rb