Class: Metasploit::Model::Search::Operator::Single Abstract
- Defined in:
- app/models/metasploit/model/search/operator/single.rb
Overview
This class is abstract.
Operator that only returns a single operation from #operate_on.
Direct Known Subclasses
Constant Summary collapse
- MODULE_SEPARATOR =
Separator between parent and child module/class names.
'::'
- OPERATION_NAMESPACE_NAME =
Name of namespace module for operations returned from #operation_class and used by #operate_on.
"Metasploit::Model::Search::Operation"
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.constant_name(type) ⇒ String
The constant name for the given type.
Instance Method Summary collapse
- #operate_on(formatted_value) ⇒ Metasploit::Model::Search::Operation::Base
-
#operation_class ⇒ Class<Metasploit::Model::Search::Operation::Base>
protected
The #type-specific Metasploit::Model::Search::Operation::Base subclass.
-
#operation_class_name ⇒ String
protected
The name of the #type-specific Metasploit::Model::Search::Operation::Base subclass.
-
#type ⇒ Symbol
abstract
Type of the attribute.
Methods inherited from Base
Methods included from Help
Methods inherited from Base
Constructor Details
This class inherits a constructor from Metasploit::Model::Base
Class Method Details
.constant_name(type) ⇒ String
The constant name for the given type.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/metasploit/model/search/operator/single.rb', line 20 def self.constant_name(type) case type when Hash if type.length < 1 raise ArgumentError, "Cannot destructure a Hash without entries" end if type.length > 1 raise ArgumentError, "Cannot destructure a Hash with multiple entries" end partial_types = type.first partial_constant_names = partial_types.collect { |partial_type| constant_name(partial_type) } partial_constant_names.join(MODULE_SEPARATOR) when Symbol type.to_s.camelize else raise ArgumentError, "Can only convert Hashes and Symbols to constant names, not #{type.inspect}" end end |
Instance Method Details
#operate_on(formatted_value) ⇒ Metasploit::Model::Search::Operation::Base
49 50 51 52 53 54 |
# File 'app/models/metasploit/model/search/operator/single.rb', line 49 def operate_on(formatted_value) operation_class.new( :value => formatted_value, :operator => self ) end |
#operation_class ⇒ Class<Metasploit::Model::Search::Operation::Base> (protected)
The #type-specific Metasploit::Model::Search::Operation::Base subclass.
72 73 74 75 76 77 78 |
# File 'app/models/metasploit/model/search/operator/single.rb', line 72 def operation_class unless instance_variable_defined? :@operation_class @operation_class = operation_class_name.constantize end @operation_class end |
#operation_class_name ⇒ String (protected)
The name of the #type-specific Metasploit::Model::Search::Operation::Base subclass.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/models/metasploit/model/search/operator/single.rb', line 84 def operation_class_name unless instance_variable_defined? :@operation_class_name unless type raise ArgumentError, "#{self.class}##{__method__} cannot be derived for #{name} operator because its type is nil" end partial_constant_names = [OPERATION_NAMESPACE_NAME] partial_constant_names << self.class.constant_name(type) @operation_class_name = partial_constant_names.join(MODULE_SEPARATOR) end @operation_class_name end |
#type ⇒ Symbol
This method is abstract.
subclass and derive operator type.
Type of the attribute.
62 63 64 |
# File 'app/models/metasploit/model/search/operator/single.rb', line 62 def type raise NotImplementedError end |