Class: Stix2::CustomObject

Inherits:
Common
  • Object
show all
Extended by:
Gem::Deprecate
Defined in:
lib/stix2/custom_object.rb

Instance Method Summary collapse

Methods inherited from Common

#confidence_scale, #method_missing, #respond_to_missing?

Constructor Details

#initialize(attributes = {}) ⇒ CustomObject

Returns a new instance of CustomObject.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/stix2/custom_object.rb', line 10

def initialize(attributes = {})
  attributes.each_key do |attribute|
    self.class.property(attribute) unless self.class.property?(attribute)
  end

  super
  h = to_hash
  h.each do |property, value|
    next if property == "id"
    raise(Exception::PropertyInvalidSize.new(property)) if property.size < 3 || property.size > 250
    raise(Exception::PropertyInvalidName.new(property)) if !property.match?(/^[a-z0-9_]*$/)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stix2::Common