Module: Defi

Defined in:


Namespace for the Defi library.

This file serves as the entry point for the Defi library, establishing the Defi namespace and requiring necessary components. It is typically required at the beginning of using the Defi library in an application.


Requiring the Defi library in a Ruby application

require "defi"

Adding 2 to 1

# Create a Defi method object for addition with an argument of 2
addition = Defi(:+, 2)
addition.inspect # => "Defi(name: :+, args: [2], opts: {}, block: nil)"

# Apply the addition to the number 1
result =
result # => Value(object: 3, raised: false)

# Execute the addition and get the result # => 3

Defined Under Namespace

Classes: Method, Value