Module: Defi

Defined in:
lib/defi.rb,
lib/defi/value.rb,
lib/defi/method.rb

Overview

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.

Examples:

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 = addition.to(1)
result # => Value(object: 3, raised: false)

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

Defined Under Namespace

Classes: Method, Value