Expose Servus::Result as a top-level primary concern - #43
Closed
fractaledmind wants to merge 1 commit into
Closed
Conversation
Add `Servus::Result` with class-method factories `.success(data = nil)` and `.failure(message = nil, data:, type:)` so the result object can be used from any code, not just inside a service class. `Servus::Base#success` / `#failure` delegate to `Result.success` / `.failure` for a single source of truth. `Servus::Support::Response` remains as a silent alias for backwards compatibility. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Schwad
approved these changes
Jun 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Servus::Resultat the top level with class-method factories.success(data = nil)and.failure(message = nil, data:, type:), so the result object can be used from any code — controllers, jobs, plain POROs — not just inside aServus::Basesubclass.Servus::Base#successand#failurenow delegate toServus::Result.success/.failure(single source of truth).Servus::Support::Responseis kept as a silent alias ofServus::Resultfor backwards compatibility — all existing references continue to resolve unchanged.Docs
site/core/responses.mdrewritten to lead withServus::Resultas the primary concept, with a dedicated "Outside a service" section before the existing "Inside a service" content. URL unchanged.CHANGELOG.mdhas an[Unreleased]entry — no version bump in this PR (suggest0.6.0since it's a new public API surface, though fully backwards-compatible).Test plan
bundle exec rspec— 783 examples, 0 failures (was 770; +13 new inspec/servus/result_spec.rb)bundle exec rubocop— 82 files, no offenses🤖 Generated with Claude Code