Module: Metasploit::Model::Derivation::ClassMethods
- Defined in:
- lib/metasploit/model/derivation.rb
Overview
Defines class methods include #derives, which can be used to declare derived attributes after mixing in Metasploit::Model::Derivation.
Instance Method Summary collapse
-
#derives(attribute, options = {}) ⇒ void
Declares that the attribute should be derived using the derived_
method if it is nil
before validation. -
#validate_by_derived_attribute ⇒ Hash{Symbol => Boolean}
Maps a derived attribute (declared with #derives) to whether the attribute should validate as a derivation.
Instance Method Details
#derives(attribute, options = {}) ⇒ void
This method returns an undefined value.
Declares that the attribute should be derived using the derived_nil
before
validation.
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/metasploit/model/derivation.rb', line 72 def derives(attribute, ={}) .assert_valid_keys(:validate) validate = .fetch(:validate, false) validate_by_derived_attribute[attribute] = validate if validate validates attribute, :derivation => true end end |
#validate_by_derived_attribute ⇒ Hash{Symbol => Boolean}
Maps a derived attribute (declared with #derives) to whether the attribute should validate as a derivation.
86 87 88 |
# File 'lib/metasploit/model/derivation.rb', line 86 def validate_by_derived_attribute @validate_by_derived_attribute ||= {} end |