Module: DSPy::Callbacks::ClassMethods

Defined in:
lib/dspy/callbacks.rb

Instance Method Summary collapse

Instance Method Details

#create_after_callback(method_name, wrap: true) ⇒ Object

Creates an after callback hook for the specified method



65
66
67
68
69
# File 'lib/dspy/callbacks.rb', line 65

def create_after_callback(method_name, wrap: true)
  mark_method_has_callbacks(method_name, wrap: wrap)
  ensure_callback_method_defined(:after, method_name)
  wrap_method_with_callbacks(method_name) if wrap
end

#create_around_callback(method_name, wrap: true) ⇒ Object

Creates an around callback hook for the specified method



74
75
76
77
78
# File 'lib/dspy/callbacks.rb', line 74

def create_around_callback(method_name, wrap: true)
  mark_method_has_callbacks(method_name, wrap: wrap)
  ensure_callback_method_defined(:around, method_name)
  wrap_method_with_callbacks(method_name) if wrap
end

#create_before_callback(method_name, wrap: true) ⇒ Object

Configures a method to expose before callbacks.

Creates a before callback hook for the specified method



56
57
58
59
60
# File 'lib/dspy/callbacks.rb', line 56

def create_before_callback(method_name, wrap: true)
  mark_method_has_callbacks(method_name, wrap: wrap)
  ensure_callback_method_defined(:before, method_name)
  wrap_method_with_callbacks(method_name) if wrap
end