Class: Rubino::API::Operations::Skills::ListOperation

Inherits:
Object
  • Object
show all
Defined in:
lib/rubino/api/operations/skills/list_operation.rb

Overview

GET /v1/skills Lists every registered skill annotated with its persisted enabled flag.

Instance Method Summary collapse

Constructor Details

#initialize(registry: nil, state_repository: nil) ⇒ ListOperation

Accepts an alternate skills registry and state repository for tests.



11
12
13
14
# File 'lib/rubino/api/operations/skills/list_operation.rb', line 11

def initialize(registry: nil, state_repository: nil)
  @registry = registry || ::Rubino::Skills::Registry.new
  @state_repository = state_repository || ::Rubino::Skills::StateRepository.new
end

Instance Method Details

#call(_request) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/rubino/api/operations/skills/list_operation.rb', line 16

def call(_request)
  skills = @registry.all.map do |skill|
    {
      name: skill.name,
      description: skill.description,
      enabled: @state_repository.enabled?(skill.name)
    }
  end
  [200, skills]
end