Class: Metasploit::Credential::Search::Operator::Type
- Inherits:
-
Model::Search::Operator::Attribute
- Object
- Model::Search::Operator::Attribute
- Metasploit::Credential::Search::Operator::Type
- Defined in:
- app/models/metasploit/credential/search/operator/type.rb
Overview
Operator that searches a polymorphic #type attribute. Search terms are restricted to set of Class#names and
Class#model_name.human with the Class#model_name.human being translated to Class#name in the operation returned
by #operate_on.
Instance Attribute Summary collapse
-
#class_names ⇒ Array<String>
The name of the classes that are allowed for #attribute.
Instance Method Summary collapse
-
#attribute ⇒ Symbol
Defaults to
:typeas all STI tables inApplicationRecordusetypeas teh type attribute by default. -
#class_name_by_class_model_name_human ⇒ Hash{String => String}
Maps
Class.model_name.humantoClass.namefor #class_set. -
#class_set ⇒ Set<Class>
Set of
Classes whoseClass#nameorClass.model_name.name. -
#operation_class_name ⇒ String
'Metasploit::Credential::Search::Operation::Type'.
-
#type ⇒ String
The type attribute for STI and polymorphic associations is a string on the database.
Instance Attribute Details
#class_names ⇒ Array<String>
The name of the classes that are allowed for #attribute. Class.names must be supplied as there's no way in
Rails to reflectively determine all allowed values for a polymorphic type.
14 |
# File 'app/models/metasploit/credential/search/operator/type.rb', line 14 attr_writer :class_names |
Instance Method Details
#attribute ⇒ Symbol
Defaults to :type as all STI tables in ApplicationRecord use type as teh type attribute by default. Override
to search foreign key types, which are prefixed with the association name.
31 32 33 |
# File 'app/models/metasploit/credential/search/operator/type.rb', line 31 def attribute @attribute ||= :type end |
#class_name_by_class_model_name_human ⇒ Hash{String => String}
Maps Class.model_name.human to Class.name for #class_set.
47 48 49 50 51 |
# File 'app/models/metasploit/credential/search/operator/type.rb', line 47 def class_name_by_class_model_name_human @class_name_by_class_model_name_human ||= class_set.each_with_object({}) { |klass, class_name_by_class_model_name_human| class_name_by_class_model_name_human[klass.model_name.human] = klass.name } end |
#class_set ⇒ Set<Class>
Set of Classes whose Class#name or Class.model_name.name
56 57 58 59 60 |
# File 'app/models/metasploit/credential/search/operator/type.rb', line 56 def class_set @class_set ||= class_names.each_with_object(Set.new) { |class_name, set| set.add class_name.constantize } end |
#operation_class_name ⇒ String
Returns 'Metasploit::Credential::Search::Operation::Type'.
63 64 65 |
# File 'app/models/metasploit/credential/search/operator/type.rb', line 63 def operation_class_name 'Metasploit::Credential::Search::Operation::Type' end |
#type ⇒ String
The type attribute for STI and polymorphic associations is a string on the database.
70 71 72 |
# File 'app/models/metasploit/credential/search/operator/type.rb', line 70 def type :string end |