Class: Metasploit::Model::Module::Instance::Spec::Template
- Extended by:
- Spec::Template::Write
- Defined in:
- app/models/metasploit/model/module/instance/spec/template.rb
Overview
Writes templates for the #module_instance's #module_class's Class#ancestors to disk.
Instance Attribute Summary collapse
-
#module_instance ⇒ Metasploit::Model::Module::Instance
The Metasploit::Model::Module::Instance whose Metasploit::Model::Module::Instance#module_class needs to be templated in #class_template.
Instance Method Summary collapse
-
#class_template ⇒ Metasploit::Model::Module::Class::Spec::Template?
Template for #module_instance Metasploit::Model::Module::Instance#module_class with the addition of #module_instance to the Spec::Template#locals and adding 'module/instances' to the front of the Spec::Template#search_pathnames.
-
#class_template_valid ⇒ void
private
Validates that #class_template is valid when present.
-
#write ⇒ void
Writes #class_template 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_instance ⇒ Metasploit::Model::Module::Instance
The Metasploit::Model::Module::Instance whose Metasploit::Model::Module::Instance#module_class needs to be templated in #class_template.
38 39 40 |
# File 'app/models/metasploit/model/module/instance/spec/template.rb', line 38 def module_instance @module_instance end |
Instance Method Details
#class_template ⇒ Metasploit::Model::Module::Class::Spec::Template?
Template for #module_instance Metasploit::Model::Module::Instance#module_class with the addition of #module_instance to the Spec::Template#locals and adding 'module/instances' to the front of the Spec::Template#search_pathnames.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/models/metasploit/model/module/instance/spec/template.rb', line 60 def class_template unless instance_variable_defined? :@class_template if module_instance class_template = Metasploit::Model::Module::Class::Spec::Template.new( module_class: module_instance.module_class ) class_template.ancestor_templates.each do |ancestor_template| ancestor_template.locals[:module_instance] = module_instance ancestor_template.search_pathnames.unshift( Pathname.new('module/instances') ) end @class_template = class_template else @class_template = nil end end @class_template end |
#class_template_valid ⇒ void (private)
This method returns an undefined value.
Validates that #class_template is valid when present.
96 97 98 99 100 |
# File 'app/models/metasploit/model/module/instance/spec/template.rb', line 96 def class_template_valid if class_template && !class_template.valid? errors.add(:class_template, :invalid, value: class_template) end end |
#write ⇒ void
This method returns an undefined value.
Writes #class_template to disk.
88 89 |
# File 'app/models/metasploit/model/module/instance/spec/template.rb', line 88 delegate :write, to: :class_template |