rails-service-object

Structure Rails service objects with dry-monads for multi-step business logic.

7|3|Updated May 25, 2015
One-click install
npx skills add https://github.com/rockcodelabs/kw-app --skill rails-service-object
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rails-service-object
Source: https://github.com/rockcodelabs/kw-app/tree/main/.agents/skills/rails-service-object
Command: npx skills add https://github.com/rockcodelabs/kw-app --skill rails-service-object

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill codifies the service object pattern in Rails apps using dry-monads to manage multi-step business logic, improving maintainability, testability, and separation of concerns.

Core Features & Use Cases

  • Guides when to use service objects: when business logic touches multiple models, involves external calls, or requires transactional boundaries.
  • Structure & Patterns: demonstrates the Namespace::Operation::Action convention and how to compose steps with do-notation.
  • Testing & Integration: provides testing approaches and controller integration patterns to ensure safe, observable changes.

Quick Start

Instantiate and run a service object via its operation class, then handle Success or Failure results in the controller or workflow.

Frequently Asked Questions about rails-service-object

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I use Rails service objects instead of models or controllers?

Use Rails service objects when business logic touches multiple models, involves external calls, or requires transactional boundaries, keeping complex rules out of controllers and models for better testability.

How do I structure a Rails service object with dry-monads?

Structure Rails service objects using the Namespace::Operation::Action convention, composing multi-step business logic with dry-monads do-notation to handle Success and Failure results cleanly.

What is the best way to test Rails service objects using dry-monads?

Test Rails service objects by instantiating the operation class, using dependency injection for mocks, and asserting Success or Failure monad results to verify multi-step business logic and external calls.

How do I integrate dry-monads service objects with Rails controllers?

Integrate dry-monads service objects in Rails controllers by instantiating the operation class, executing it, and pattern matching the Success or Failure results to render appropriate responses or redirect.

Does using dry-monads for Rails service objects require dependency injection?

Yes, this Rails service object architecture enforces using dry-monads alongside dependency injection to isolate external calls and ensure multi-step business logic is fully testable and maintainable.