Module: ActiveAgent::Previews::ClassMethods

Defined in:
lib/active_agent/preview.rb

Instance Method Summary collapse

Instance Method Details

#register_preview_interceptor(interceptor) ⇒ Object

Register an Interceptor which will be called before prompt is previewed. Either a class or a string can be passed in as the Interceptor. If a string is passed in it will be constantized.



31
32
33
34
35
36
37
# File 'lib/active_agent/preview.rb', line 31

def register_preview_interceptor(interceptor)
  preview_interceptor = interceptor_class_for(interceptor)

  unless preview_interceptors.include?(preview_interceptor)
    preview_interceptors << preview_interceptor
  end
end

#register_preview_interceptors(*interceptors) ⇒ Object

Register one or more Interceptors which will be called before prompt is previewed.



19
20
21
# File 'lib/active_agent/preview.rb', line 19

def register_preview_interceptors(*interceptors)
  interceptors.flatten.compact.each { |interceptor| register_preview_interceptor(interceptor) }
end

#unregister_preview_interceptor(interceptor) ⇒ Object

Unregister a previously registered Interceptor. Either a class or a string can be passed in as the Interceptor. If a string is passed in it will be constantized.



42
43
44
# File 'lib/active_agent/preview.rb', line 42

def unregister_preview_interceptor(interceptor)
  preview_interceptors.delete(interceptor_class_for(interceptor))
end

#unregister_preview_interceptors(*interceptors) ⇒ Object

Unregister one or more previously registered Interceptors.



24
25
26
# File 'lib/active_agent/preview.rb', line 24

def unregister_preview_interceptors(*interceptors)
  interceptors.flatten.compact.each { |interceptor| unregister_preview_interceptor(interceptor) }
end