Class: Stix2::Common
- Includes:
- Hashie::Extensions::Dash::PropertyTranslation
- Defined in:
- lib/stix2/common.rb
Direct Known Subclasses
Bundle, CustomObject, Stix2::CyberobservableObject::Base, DomainObject::Base, ExtensionDefinition, MetaObject::Base, MetaObject::DataMarking::MarkingDefinition, RelationshipObject::Base
Instance Method Summary collapse
- #confidence_scale ⇒ Object
-
#initialize(options = {}) ⇒ Common
constructor
A new instance of Common.
- #method_missing(m, *args, &block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Common
Returns a new instance of Common.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/stix2/common.rb', line 25 def initialize( = {}) = .dup Hashie.symbolize_keys!() set_strict() guess_type() autogenerate_id() process_toplevel_property_extension([:extensions]) super() process_extensions() validate_confidence! if @strict Stix2::Storage.add(self) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/stix2/common.rb', line 38 def method_missing(m, *args, &block) if !m.to_s.end_with?("_instance") # :nocov: super(m, args, block) return # :nocov: end # Retrieve the original method ref_method = m.to_s.gsub(/_instance$/, "") obj_id = public_send(ref_method) Stix2::Storage.find(obj_id) end |
Instance Method Details
#confidence_scale ⇒ Object
55 56 57 |
# File 'lib/stix2/common.rb', line 55 def confidence_scale Stix2::ConfidenceScale.new(confidence) end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
51 52 53 |
# File 'lib/stix2/common.rb', line 51 def respond_to_missing?(method_name, include_private = false) method_name.to_s.start_with?("_instance") || super end |