module MetasploitDataModels::Match::Parent

Uses classes that extend {MetasploitDataModels::Match::Child}

@example Add #match_child to class.

class Parent
  include MetasploitDataModels::Match::Parent

  match_children_named %w{FirstChild SecondChild}
end

Public Instance Methods

match_child(formatted_value) click to toggle source

@param formatted_value [#to_s] A formatted value for the child's `#value`. @return [Object] instance of the first of {ClassMethods#match_children} that matches the `formatted_value`. @return [nil] if no {ClassMethods#match_children} matches the `formatted_value`.

# File lib/metasploit_data_models/match/parent.rb, line 90
def match_child(formatted_value)
  child = nil

  self.class.match_children.each do |child_class|
    child = child_class.match(formatted_value)

    if child
      break
    end
  end

  child
end