Class: ApiReference::NewItem

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

Overview

NewItem 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(name:, metadata: SKIP) ⇒ NewItem

Returns a new instance of NewItem.



44
45
46
47
# File 'lib/api_reference/models/new_item.rb', line 44

def initialize(name:, metadata: SKIP)
  @metadata =  unless  == SKIP
  @name = name
end

Instance Attribute Details

#metadataHash[String, String]

User-specified key/value pairs for the resource. Individual keys can be removed by setting the value to null, and the entire metadata mapping can be cleared by setting metadata to null.

Returns:

  • (Hash[String, String])


16
17
18
# File 'lib/api_reference/models/new_item.rb', line 16

def 
  @metadata
end

#nameString

The name of the item.

Returns:

  • (String)


20
21
22
# File 'lib/api_reference/models/new_item.rb', line 20

def name
  @name
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/api_reference/models/new_item.rb', line 50

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : nil
   = hash.key?('metadata') ? hash['metadata'] : SKIP

  # Create object from extracted values.
  NewItem.new(name: name,
              metadata: )
end

.namesObject

A mapping from model property names to API property names.



23
24
25
26
27
28
# File 'lib/api_reference/models/new_item.rb', line 23

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

.nullablesObject

An array for nullable fields



38
39
40
41
42
# File 'lib/api_reference/models/new_item.rb', line 38

def self.nullables
  %w[
    metadata
  ]
end

.optionalsObject

An array for optional fields



31
32
33
34
35
# File 'lib/api_reference/models/new_item.rb', line 31

def self.optionals
  %w[
    metadata
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



69
70
71
72
# File 'lib/api_reference/models/new_item.rb', line 69

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

#to_sObject

Provides a human-readable string representation of the object.



63
64
65
66
# File 'lib/api_reference/models/new_item.rb', line 63

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