Module: Gaskit

Defined in:
lib/gaskit.rb,
lib/gaskit/core.rb,
lib/gaskit/flow.rb,
lib/gaskit/error.rb,
lib/gaskit/logger.rb,
lib/gaskit/helpers.rb,
lib/gaskit/railtie.rb,
lib/gaskit/version.rb,
lib/gaskit/hookable.rb,
lib/gaskit/operation.rb,
lib/gaskit/boot/query.rb,
lib/gaskit/repository.rb,
lib/gaskit/flow_result.rb,
lib/gaskit/boot/service.rb,
lib/gaskit/configuration.rb,
lib/gaskit/hook_registry.rb,
lib/gaskit/operation_exit.rb,
lib/gaskit/operation_result.rb,
lib/gaskit/contract_registry.rb,
lib/generators/gaskit/operation/flow_generator.rb,
lib/generators/gaskit/operation/query_generator.rb,
lib/generators/gaskit/operation/service_generator.rb,
lib/generators/gaskit/operation/operation_generator.rb,
lib/generators/gaskit/operation/repository_generator.rb

Overview

Gaskit is a lightweight, extensible framework for building structured application operations.

It provides a clear architecture for defining, executing, and managing operations, supporting common patterns like services and queries, early exits, context-aware logging, and standardized result wrapping.

Examples:

Configuring Gaskit

Gaskit.config do |c|
  c.setup_logger(Logger.new(STDOUT), level: ::Logger::INFO, formatter: Gaskit::Logger.formatter(:json))
  c.context_provider = -> { { request_id: SecureRandom.uuid } }
end

Registering a contract

Gaskit.contracts.register(:service, MyResultClass)

Defining a service

class MyService < Gaskit::Service
  def call
    # do work
    "done"
  end
end

See Also:

Defined Under Namespace

Modules: Generators, Helpers, Hookable Classes: Configuration, ContractError, ContractRegistry, Error, Flow, FlowResult, HookRegistry, Logger, Operation, OperationExit, OperationResult, Query, QueryResult, Railtie, Repository, ResultTypeError, Service, ServiceResult

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.config {|configuration| ... } ⇒ void

This method returns an undefined value.

Configures the Gaskit system.

This yields the configuration instance, allowing you to modify settings such as logger, global context, log level, and formatting.

Yield Parameters:



15
16
17
# File 'lib/gaskit/core.rb', line 15

def config
  yield(configuration)
end

.configurationGaskit::Configuration

Retrieves the global Gaskit configuration.

Returns:



22
23
24
# File 'lib/gaskit/core.rb', line 22

def configuration
  @configuration ||= Configuration.new
end

.contractsGaskit::ContractRegistry

Returns configuration.contracts.

Returns:



36
37
38
# File 'lib/gaskit/core.rb', line 36

def contracts
  configuration.contracts
end

.debug?Boolean

Returns configuration.debug.

Returns:

  • (Boolean)

    ‘true` is Gaskit is set to debug, `false` otherwise.



29
30
31
# File 'lib/gaskit/core.rb', line 29

def debug?
  Gaskit.configuration.debug
end

.hooksGaskit::HookRegistry

Returns configuration.hooks.

Returns:



43
44
45
# File 'lib/gaskit/core.rb', line 43

def hooks
  configuration.hooks
end