Sha256: 97e0e4760fd6a245494c7190cc60d663342d3befa5978dd954442f2c307e8eba

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require "dry/operation"
require "dry/operation/extensions/rom"

module Hanami
  module Extensions
    # Integrated behavior for `Dry::Operation` classes within Hanami apps.
    #
    # @see https://github.com/dry-rb/dry-operation
    #
    # @api public
    # @since 2.2.0
    module Operation
      # @api private
      # @since 2.2.0
      def self.included(operation_class)
        super

        operation_class.extend(Hanami::SliceConfigurable)
        operation_class.extend(ClassMethods)
      end

      # @api private
      # @since 2.2.0
      module ClassMethods
        # @api private
        # @since 2.2.0
        def configure_for_slice(slice)
          include slice.namespace::Deps["db.rom"]
        end

        # @api private
        # @since 2.2.0
        def inherited(subclass)
          super

          return unless subclass.superclass == self
          return unless Hanami.bundled?("hanami-db")

          subclass.include Dry::Operation::Extensions::ROM
        end
      end
    end
  end
end

Dry::Operation.include(Hanami::Extensions::Operation)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hanami-2.2.0 lib/hanami/extensions/operation.rb
hanami-2.2.0.rc1 lib/hanami/extensions/operation.rb