Module: Defi

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

Overview

Namespace for the Defi library.

Defi provides a flexible way to specify method calls with arguments for later execution. It supports method chaining, exception handling, and value inspection.

Examples:

Basic arithmetic operation

addition = Defi(:+, 2)
addition.to(1).call # => 3

String manipulation

upcase = Defi(:upcase)
upcase.to("hello").call # => "HELLO"

Method with keyword arguments

format = Defi(:format, precision: 2)
format.to(3.14159).call # => "3.14"

Block usage

map_double = Defi(:map) { |x| x * 2 }
map_double.to([1, 2, 3]).call # => [2, 4, 6]

Error handling

result = Defi(:undefined_method).to(42)
result.raised? # => true
result.object # => #<NoMethodError: ...>

Defined Under Namespace

Classes: Method, Value