Class: MistApi::VarsAnnotation

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/vars_annotation.rb

Overview

Annotation for a single var, helping identify its purpose and enabling auto-complete/enumeration in UI

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(note = SKIP, type = 'generic') ⇒ VarsAnnotation

Returns a new instance of VarsAnnotation.



44
45
46
47
# File 'lib/mist_api/models/vars_annotation.rb', line 44

def initialize(note = SKIP, type = 'generic')
  @note = note unless note == SKIP
  @type = type unless type == SKIP
end

Instance Attribute Details

#noteString

User-provided note to describe what this var was created for

Returns:

  • (String)


15
16
17
# File 'lib/mist_api/models/vars_annotation.rb', line 15

def note
  @note
end

#typeString

Used to identify where to enumerate / auto-complete the field from. Default is ‘generic` (plain string, no special handling). enum: `generic`, `mxtunnel_id`

Returns:

  • (String)


21
22
23
# File 'lib/mist_api/models/vars_annotation.rb', line 21

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/mist_api/models/vars_annotation.rb', line 50

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  note = hash.key?('note') ? hash['note'] : SKIP
  type = hash['type'] ||= 'generic'

  # Create object from extracted values.
  VarsAnnotation.new(note,
                     type)
end

.namesObject

A mapping from model property names to API property names.



24
25
26
27
28
29
# File 'lib/mist_api/models/vars_annotation.rb', line 24

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['note'] = 'note'
  @_hash['type'] = 'type'
  @_hash
end

.nullablesObject

An array for nullable fields



40
41
42
# File 'lib/mist_api/models/vars_annotation.rb', line 40

def self.nullables
  []
end

.optionalsObject

An array for optional fields



32
33
34
35
36
37
# File 'lib/mist_api/models/vars_annotation.rb', line 32

def self.optionals
  %w[
    note
    type
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



69
70
71
72
# File 'lib/mist_api/models/vars_annotation.rb', line 69

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} note: #{@note.inspect}, type: #{@type.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



63
64
65
66
# File 'lib/mist_api/models/vars_annotation.rb', line 63

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} note: #{@note}, type: #{@type}>"
end