Module: LLM::Contract
- Included in:
- Completion
- Defined in:
- lib/llm/contract.rb,
lib/llm/contract/completion.rb
Overview
The LLM::Contract module provides the ability for modules
who are extended by it to implement contracts which must be
implemented by other modules who include a given contract.
Defined Under Namespace
Modules: Completion
Constant Summary collapse
Instance Method Summary collapse
- #included(mod) ⇒ Object private
Instance Method Details
#included(mod) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/llm/contract.rb', line 37 def included(mod) meths = mod.instance_methods(false) if meths.empty? raise ContractError, "#{mod} does not implement any methods required by #{self}" end missing = instance_methods - meths if missing.any? raise ContractError, "#{mod} does not implement methods (#{missing.join(", ")}) required by #{self}" end end |