Class: ActiveRecordVector::Providers::Custom
- Defined in:
- lib/active_record_vector/providers/custom.rb
Overview
Custom provider allowing any Proc, Lambda, or custom object responding to #call or #embed
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from ActiveRecordVector::Providers::Base
Instance Method Details
#embed(text) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/active_record_vector/providers/custom.rb', line 7 def (text) callable = [:with] || [:proc] raise Error, "Custom provider requires options[:with] to be a Proc or object responding to #call" unless callable if callable.respond_to?(:call) callable.call(text) elsif callable.respond_to?(:embed) callable.(text) else raise Error, "Custom provider options[:with] must respond to #call or #embed" end end |