Class: Rubino::API::Operations::Skills::ListOperation
- Inherits:
-
Object
- Object
- Rubino::API::Operations::Skills::ListOperation
- Defined in:
- lib/rubino/api/operations/skills/list_operation.rb
Overview
GET /v1/skills Lists every registered skill annotated with its persisted enabled flag.
Class Method Summary collapse
Instance Method Summary collapse
- #call(_request) ⇒ Object
-
#initialize(registry: nil, state_repository: nil) ⇒ ListOperation
constructor
Accepts an alternate skills registry and state repository for tests.
Constructor Details
#initialize(registry: nil, state_repository: nil) ⇒ ListOperation
Accepts an alternate skills registry and state repository for tests.
15 16 17 18 |
# File 'lib/rubino/api/operations/skills/list_operation.rb', line 15 def initialize(registry: nil, state_repository: nil) @registry = registry || ::Rubino::Skills::Registry.new @state_repository = state_repository || ::Rubino::Skills::StateRepository.new end |
Class Method Details
.call(request) ⇒ Object
10 11 12 |
# File 'lib/rubino/api/operations/skills/list_operation.rb', line 10 def self.call(request) new.call(request) end |
Instance Method Details
#call(_request) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rubino/api/operations/skills/list_operation.rb', line 20 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 |