Class: Metasploit::Model::Search::Operation::Set
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- app/models/metasploit/model/search/operation/set.rb
Overview
Operation on an attribute that has a constrained Set of valid values.
Defined Under Namespace
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#membership ⇒ void
private
Validates that Base#value is a member of Base#operator Metasploit::Model::Search::Operator::Attribute#attribute_set.
Methods inherited from Base
Methods inherited from Base
Constructor Details
This class inherits a constructor from Metasploit::Model::Base
Instance Method Details
#membership ⇒ void (private)
This method returns an undefined value.
Validates that Base#value is a member of Base#operator Metasploit::Model::Search::Operator::Attribute#attribute_set.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/models/metasploit/model/search/operation/set.rb', line 21 def membership if operator attribute_set = operator.attribute_set unless attribute_set.include? value # sort (because Sets are unordered) before inspecting so that lexigraphical sorting is NOT used sorted = attribute_set.sort # use inspect to differentiate between strings and integers or string and symbols inspected = sorted.map(&:inspect) # format as a human readable Set using { } comma_separated = inspected.join(', ') human_set = "{#{comma_separated}}" errors.add(:value, :inclusion, set: human_set) end end end |