Class: Apiwork::Introspection::Param::Binary

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

Overview

Binary param representing base64-encoded binary data.

Examples:

Basic usage

param.type # => :binary
param.scalar? # => true
param.binary? # => true

Capabilities

param.formattable? # => false

Enum

if param.enum?
  param.enum # => ["SGVsbG8=", "V29ybGQ="]
  param.enum_reference? # => false
end

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

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

Instance Method Details

#binary?Boolean

Whether this param is binary data.

Returns:



86
87
88
# File 'lib/apiwork/introspection/param/binary.rb', line 86

def binary?
  true
end

#concrete?Boolean

Whether this param is concrete.

Returns:



46
47
48
# File 'lib/apiwork/introspection/param/binary.rb', line 46

def concrete?
  true
end

#defaultObject?

The default for this param.

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

Returns:



30
31
32
# File 'lib/apiwork/introspection/param/binary.rb', line 30

def default
  @dump[:default]
end

#enumArray<String>, ...

The enum for this param.

Returns:



70
71
72
# File 'lib/apiwork/introspection/param/binary.rb', line 70

def enum
  @dump[:enum]
end

#enum?Boolean

Whether this param has an enum.

Returns:



62
63
64
# File 'lib/apiwork/introspection/param/binary.rb', line 62

def enum?
  @dump[:enum].present?
end

#enum_reference?Boolean

Whether this param is an enum reference.

Returns:



78
79
80
# File 'lib/apiwork/introspection/param/binary.rb', line 78

def enum_reference?
  @dump[:enum].is_a?(Symbol)
end

#exampleObject?

The example for this param.

Returns:



38
39
40
# File 'lib/apiwork/introspection/param/binary.rb', line 38

def example
  @dump[:example]
end

#formattable?Boolean

Whether this param is formattable.

Returns:



94
95
96
# File 'lib/apiwork/introspection/param/binary.rb', line 94

def formattable?
  false
end

#scalar?Boolean

Whether this param is scalar.

Returns:



54
55
56
# File 'lib/apiwork/introspection/param/binary.rb', line 54

def scalar?
  true
end

#to_hHash

Converts this param to a hash.

Returns:

  • (Hash)


102
103
104
105
106
107
108
# File 'lib/apiwork/introspection/param/binary.rb', line 102

def to_h
  result = super
  result[:default] = default
  result[:enum] = enum if enum?
  result[:example] = example
  result
end