Socket
Book a DemoInstallSign in
Socket

domainic-command

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

domainic-command

0.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

Domainic::Command

Domainic::Command Version Domainic::Command License Domainic::Command Docs Domainic::Command Open Issues

A robust implementation of the Command pattern for Ruby applications, providing type-safe, self-documenting business operations with standardized error handling and composable workflows.

Tired of scattered business logic and unclear error handling? Domainic::Command brings clarity to your domain operations by:

  • Enforcing explicit input/output contracts with type validation
  • Providing consistent error handling and status reporting
  • Enabling self-documenting business operations
  • Supporting composable command workflows
  • Maintaining thread safety for concurrent operations

Quick Start

class CreateUser
  include Domainic::Command

  # Define expected inputs with validation
  argument :login, String, "The user's login", required: true
  argument :password, String, "The user's password", required: true

  # Define expected outputs
  output :user, User, "The created user", required: true
  output :created_at, Time, "When the user was created"

  def execute
    user = User.create!(login: context.login, password: context.password)
    context.user = user
    context.created_at = Time.current
  end
end

# Success case
result = CreateUser.call(login: "user@example.com", password: "secret123")
result.successful? # => true
result.user       # => #<User id: 1, login: "user@example.com">

# Failure case
result = CreateUser.call(login: "invalid")
result.failure?   # => true
result.errors     # => { password: ["is required"] }

Installation

Add this line to your application's Gemfile:

gem 'domainic-command'

Or install it yourself as:

gem install domainic-command

Key Features

  • Type-Safe Arguments: Define and validate input parameters with clear type constraints
  • Explicit Outputs: Specify expected return values and their requirements
  • Standardized Error Handling: Consistent error reporting with detailed failure information
  • Thread Safety: Built-in thread safety for class definition and execution
  • Command Composition: Build complex workflows by combining simpler commands
  • Self-Documenting: Generate clear documentation from your command definitions
  • Framework Agnostic: Use with any Ruby application (Rails, Sinatra, pure Ruby)

Documentation

For detailed usage instructions and examples, see USAGE.md.

Contributing

We welcome contributions! Please see our Contributing Guidelines for:

  • Development setup and workflow
  • Code style and documentation standards
  • Testing requirements
  • Pull request process

Before contributing, please review our Code of Conduct.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 29 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.