Class: ApiReference::MetricGroup

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/metric_group.rb

Overview

MetricGroup Model.

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(property_key:, property_value:, additional_properties: nil) ⇒ MetricGroup

Returns a new instance of MetricGroup.



38
39
40
41
42
43
44
45
# File 'lib/api_reference/models/metric_group.rb', line 38

def initialize(property_key:, property_value:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @property_key = property_key
  @property_value = property_value
  @additional_properties = additional_properties
end

Instance Attribute Details

#property_keyString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/api_reference/models/metric_group.rb', line 14

def property_key
  @property_key
end

#property_valueString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/api_reference/models/metric_group.rb', line 18

def property_value
  @property_value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/api_reference/models/metric_group.rb', line 48

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  property_key = hash.key?('property_key') ? hash['property_key'] : nil
  property_value =
    hash.key?('property_value') ? hash['property_value'] : nil

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  MetricGroup.new(property_key: property_key,
                  property_value: property_value,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



21
22
23
24
25
26
# File 'lib/api_reference/models/metric_group.rb', line 21

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

.nullablesObject

An array for nullable fields



34
35
36
# File 'lib/api_reference/models/metric_group.rb', line 34

def self.nullables
  []
end

.optionalsObject

An array for optional fields



29
30
31
# File 'lib/api_reference/models/metric_group.rb', line 29

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (MetricGroup | Hash)

    value against the validation is performed.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/api_reference/models/metric_group.rb', line 71

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.property_key,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.property_value,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['property_key'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['property_value'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



99
100
101
102
103
# File 'lib/api_reference/models/metric_group.rb', line 99

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} property_key: #{@property_key.inspect}, property_value:"\
  " #{@property_value.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



92
93
94
95
96
# File 'lib/api_reference/models/metric_group.rb', line 92

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} property_key: #{@property_key}, property_value: #{@property_value},"\
  " additional_properties: #{@additional_properties}>"
end