Class: Apiwork::Introspection::Enum

Inherits:
Object
  • Object
show all
Defined in:
lib/apiwork/introspection/enum.rb

Overview

Wraps enum type definitions.

Examples:

api.enums[:status].values # => ["draft", "published", "archived"]
api.enums[:status].description # => "Document status"
api.enums[:status].deprecated? # => false

Instance Method Summary collapse

Constructor Details

#initialize(dump) ⇒ Enum

Returns a new instance of Enum.



13
14
15
# File 'lib/apiwork/introspection/enum.rb', line 13

def initialize(dump)
  @dump = dump
end

Instance Method Details

#deprecated?Boolean

Whether this enum is deprecated.

Returns:

  • (Boolean)


53
54
55
# File 'lib/apiwork/introspection/enum.rb', line 53

def deprecated?
  @dump[:deprecated]
end

#descriptionString?

The description for this enum.

Returns:

  • (String, nil)


29
30
31
# File 'lib/apiwork/introspection/enum.rb', line 29

def description
  @dump[:description]
end

#exampleString?

The example for this enum.

Returns:

  • (String, nil)


37
38
39
# File 'lib/apiwork/introspection/enum.rb', line 37

def example
  @dump[:example]
end

#scopeString?

The scope for this enum.

Returns:

  • (String, nil)


45
46
47
# File 'lib/apiwork/introspection/enum.rb', line 45

def scope
  @dump[:scope]
end

#to_hHash

Converts this enum to a hash.

Returns:

  • (Hash)


61
62
63
64
65
66
67
68
69
# File 'lib/apiwork/introspection/enum.rb', line 61

def to_h
  {
    deprecated: deprecated?,
    description: description,
    example: example,
    scope: scope,
    values: values,
  }
end

#valuesArray<String>

The values for this enum.

Returns:

  • (Array<String>)


21
22
23
# File 'lib/apiwork/introspection/enum.rb', line 21

def values
  @dump[:values]
end