Class: Metasploit::Model::Module::Class::Spec::Template
- Extended by:
- Spec::Template::Write
- Defined in:
- app/models/metasploit/model/module/class/spec/template.rb
Overview
Writes templates for the #module_class's Metasploit::Model::Module::Class#ancestors to disk.
Instance Attribute Summary collapse
-
#module_class ⇒ Metasploit::Model::Module::Class
The Metasploit::Model::Module::Class whose Metasploit::Model::Module::Class#ancestors need to be templated in #ancestor_templates.
Instance Method Summary collapse
-
#ancestor_templates ⇒ Array<Metasploit::Model::Module::Ancestor::Spec::Template>, []
Template for #module_class Metasploit::Model::Module::Class#ancestors with the addition of #module_class to the Spec::Template#locals and adding 'module/classes' to the front of the Spec::Template#search_pathnames.
-
#ancestor_templates_valid ⇒ void
private
Validates that all #ancestor_templates are valid.
-
#write ⇒ void
Writes #ancestor_templates to disk.
Methods included from Spec::Template::Write
Methods inherited from Base
Constructor Details
This class inherits a constructor from Metasploit::Model::Base
Instance Attribute Details
#module_class ⇒ Metasploit::Model::Module::Class
The Metasploit::Model::Module::Class whose Metasploit::Model::Module::Class#ancestors need to be templated in #ancestor_templates.
31 32 33 |
# File 'app/models/metasploit/model/module/class/spec/template.rb', line 31 def module_class @module_class end |
Instance Method Details
#ancestor_templates ⇒ Array<Metasploit::Model::Module::Ancestor::Spec::Template>, []
Template for #module_class Metasploit::Model::Module::Class#ancestors with the addition of #module_class to the Spec::Template#locals and adding 'module/classes' to the front of the Spec::Template#search_pathnames.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/metasploit/model/module/class/spec/template.rb', line 51 def ancestor_templates unless instance_variable_defined? :@ancestor_templates if module_class @ancestor_templates = module_class.ancestors.collect { |module_ancestor| Metasploit::Model::Module::Ancestor::Spec::Template.new( module_ancestor: module_ancestor ).tap { |module_ancestor_template| module_ancestor_template.locals[:module_class] = module_class module_ancestor_template.overwrite = true module_ancestor_template.search_pathnames.unshift( Pathname.new('module/classes') ) } } end @ancestor_templates ||= [] end @ancestor_templates end |
#ancestor_templates_valid ⇒ void (private)
This method returns an undefined value.
Validates that all #ancestor_templates are valid.
87 88 89 90 91 92 93 94 95 |
# File 'app/models/metasploit/model/module/class/spec/template.rb', line 87 def ancestor_templates_valid # can't use ancestor_templates.all?(&:valid?) as it will short-circuit and want all ancestor_templates to have # validation errors valids = ancestor_templates.map(&:valid?) unless valids.all? errors.add(:ancestor_templates, :invalid, value: ancestor_templates) end end |
#write ⇒ void
This method returns an undefined value.
Writes #ancestor_templates to disk.
78 79 80 |
# File 'app/models/metasploit/model/module/class/spec/template.rb', line 78 def write ancestor_templates.each(&:write) end |