搜索

PythonReactSEOPDF
GitHub Skill

business-logic-coder

Implement business logic with ActiveInteraction and AASM state machines. Routes to specialized skills for typed operations and state management.

majesticlabs-dev☆ 20 仓库 Stars3 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Business Logic Patterns

Orchestrator for structured business logic in Rails.

Skill Routing

Need Skill Use When
Typed operations active-interaction-coder Creating business operations, refactoring service objects
State machines aasm-coder Implementing workflows, managing state transitions

When to Use Each

ActiveInteraction

Use for operations - things that happen once:

  • User registration
  • Order placement
  • Payment processing
  • Data imports
  • Report generation
# Example: One-time operation with typed inputs
outcome = Users::Create.run(email: email, name: name)
AASM

Use for state management - things with lifecycle:

  • Order status (pending → paid → shipped)
  • Subscription state (trial → active → cancelled)
  • Document workflow (draft → review → published)
  • Task status (todo → in_progress → done)
# Example: Stateful entity with transitions
order.pay!  # pending → paid
order.ship! # paid → shipped

Combined Pattern

Often used together - interactions trigger state changes:

module Orders
  class Process < ActiveInteraction::Base
    object :order, class: Order

    def execute
      order.process!  # AASM transition
      fulfill_order(order)
      order
    end
  end
end

Setup

# Gemfile
gem "active_interaction", "~> 5.3"
gem "aasm", "~> 5.5"

Quick Reference

ActiveInteraction:

  • .run - Returns outcome (check .valid?)
  • .run! - Raises on failure
  • compose - Call nested interactions

AASM:

  • .event! - Transition or raise
  • .event - Transition or return false
  • .may_event? - Check if transition valid
  • .aasm.events - List available events

Related Skills

  • event-sourcing-coder - Record domain events from state transitions

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-02-04
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!