بنقرة واحدة
service-objects
Service object patterns, Result objects, and validation conventions for this Rails codebase
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Service object patterns, Result objects, and validation conventions for this Rails codebase
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Create, execute, update, and complete implementation plans and trackers following Linkvan API conventions
Standardized Ruby gem update workflow with version checking, breaking change analysis, security advisory detection, and testing
Controller patterns, service delegation, strong parameters, and HTTP conventions for this Rails codebase
RuboCop metrics, Brakeman security, code style conventions, and quality checks for this Rails codebase
Database migration patterns, reversible migrations, indexes, and conventions for this Rails codebase
ActiveRecord model patterns, validations, scopes, and conventions for this Rails codebase
| name | service-objects |
| description | Service object patterns, Result objects, and validation conventions for this Rails codebase |
All services inherit from ApplicationService and follow this structure:
class MyService < ApplicationService
def initialize(arg1, arg2)
super()
@arg1 = arg1
@arg2 = arg2
end
def call
return Result.new(errors: ["validation error"]) unless valid?
Result.new(data: result_data)
end
private
def validate
add_error("Invalid input") if invalid_condition?
end
end
# Call service directly
result = MyService.call(arg1, arg2)
# Check for errors
if result.errors.any?
# Handle errors
else
# Use result.data
end
FacilitySerializer)facility_serializer.rbapp/services/ directoryResult objectsResult.new(errors: [...]) for validation failuresResult.new(data: ...) for successful operationsresult.errors.any? to determine success/failurevalidate methods for validation logicadd_error(message) to collect validation errorsraise for programmer errorsResult.new(errors: [...]) for service object validation failuresbegin/rescue blocks when necessaryspec/services/*_service_spec.rb suffix (e.g., facility_serializer_spec.rb)