Class: Stix2::CustomObject
- Includes:
- Hashie::Extensions::IgnoreUndeclared
- Defined in:
- lib/stix2/custom_object.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ CustomObject
constructor
A new instance of CustomObject.
Methods inherited from Common
#confidence_scale, #method_missing, #respond_to_missing?
Constructor Details
#initialize(options) ⇒ CustomObject
Returns a new instance of CustomObject.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/stix2/custom_object.rb', line 7 def initialize() Hashie.symbolize_keys!() raise("A CustomObject must have at least one property") if [:type] && .count == 1 errors = Hash.new { |k, v| k[v] = [] } .each do |key, value| errors["Too short"] << key if key != :id && key.size < 3 errors["Invalid name"] << key if !key.match?(/^[a-z0-9_]*$/) errors["Too long"] << key if key.size > 250 end raise("Error creating CustomObject: #{errors}") if !errors.empty? super() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Stix2::Common