Class: Sinclair::MethodDefinition::Stringifier Private

Inherits:
Object
  • Object
show all
Defined in:
lib/sinclair/method_definition/stringifier.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Stringgify a value for StringDefinition

Author:

  • darthjee

Class Method Summary collapse

Class Method Details

.value_string(value) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Convert a value to a string format

The returned string can be evaluated as code, returning the original value

Parameters:

  • value (Object)

    object to be converted

Returns:

  • (String)


20
21
22
23
24
25
26
27
# File 'lib/sinclair/method_definition/stringifier.rb', line 20

def self.value_string(value)
  return 'nil' if value.nil?
  return ":#{value}" if value.is_a?(Symbol)

  return value.to_s if value.is_any?(Class, Hash, Array)

  value.to_json
end