Skip to main content

default

Allows you to specify a fallback in case a value doesn’t exist. default will show its value if the left side is falsy or empty (string or Array). In this example, product_price is not defined, so the default value is used.
In this example, product_price is defined, so the default value is not used.
In this example, product_price is empty, so the default value is used.

Allowing false

To allow variables to return false instead of the default value, you can use the allow_false parameter.

json

Convert values to string via JSON.stringify(), for debug purpose.

parse_json

Convert a string value to a valid JSON object. If the value is not a valid JSON, the returned value will be nil.

Space

An additional space parameter can be specified to format the JSON.

jsonify

See json.

inspect

Similar with json, but inspect allows cyclic structure. For the scope below:

Formatting

An additional space argument can be specified for the indent width.

to_integer

Convert values to number.