Class: Apiwork::Introspection::Param::Literal

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

Overview

Literal param representing a constant value.

Examples:

Basic usage

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

Value

param.value # => "active" or 42 or true

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

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

Instance Method Details

#literal?Boolean

Whether this param is a literal.

Returns:



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

def literal?
  true
end

#to_hHash

Converts this param to a hash.

Returns:

  • (Hash)


37
38
39
40
41
# File 'lib/apiwork/introspection/param/literal.rb', line 37

def to_h
  result = super
  result[:value] = value
  result
end

#valueString, ...

The value for this param.

Returns:



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

def value
  @dump[:value]
end