Class: Apiwork::Introspection::Param::Record

Inherits:
Base
  • Object
show all
Defined in:
lib/apiwork/introspection/param/record.rb

Overview

Record param representing key-value maps with typed values.

Examples:

Basic usage

param.type # => :record
param.record? # => true
param.scalar? # => false

Value type

param.of # => Param (value type) or nil

Instance Method Summary collapse

Methods inherited from Base

#array?, #binary?, #boolean?, #boundable?, #date?, #datetime?, #decimal?, #default?, #deprecated?, #description, #enum?, #enum_reference?, #formattable?, #initialize, #integer?, #literal?, #nullable?, #number?, #numeric?, #object?, #optional?, #partial?, #reference?, #scalar?, #string?, #tag, #time?, #type, #union?, #unknown?, #uuid?

Constructor Details

This class inherits a constructor from Apiwork::Introspection::Param::Base

Instance Method Details

#concrete?Boolean

Whether this param is concrete.

Returns:



56
57
58
# File 'lib/apiwork/introspection/param/record.rb', line 56

def concrete?
  true
end

#defaultObject?

The default for this param.

Returns ‘nil` for both “no default” and “default is explicitly `nil`”. Use Base#default? to distinguish these cases.

Returns:



24
25
26
# File 'lib/apiwork/introspection/param/record.rb', line 24

def default
  @dump[:default]
end

#exampleObject?

The example for this param.

Returns:



32
33
34
# File 'lib/apiwork/introspection/param/record.rb', line 32

def example
  @dump[:example]
end

#ofParam::Base?

The value type for this record.

Returns:



40
41
42
# File 'lib/apiwork/introspection/param/record.rb', line 40

def of
  @of ||= @dump[:of] ? Param.build(@dump[:of]) : nil
end

#record?Boolean

Whether this param is a record.

Returns:



48
49
50
# File 'lib/apiwork/introspection/param/record.rb', line 48

def record?
  true
end

#to_hHash

Converts this param to a hash.

Returns:

  • (Hash)


64
65
66
67
68
69
70
# File 'lib/apiwork/introspection/param/record.rb', line 64

def to_h
  result = super
  result[:default] = default
  result[:example] = example
  result[:of] = of&.to_h
  result
end