Sha256: c8d1f75176b903f1d1258e17c1e689771657dad6f6b582475e30edd5ac028411

Contents?: true

Size: 647 Bytes

Versions: 2

Compression:

Stored size: 647 Bytes

Contents

# frozen_string_literal: true

require 'neco/container'

module Neco
  # Composition is a module for users to compose multiple commands.
  module Composition
    def self.included(base)
      base.class_eval do
        extend ClassMethods
      end
    end

    # DSLs for composition pattern.
    # `compose` is meant to be used in a class definition
    # while `call` is meant to be used when users actually execute commands.
    module ClassMethods
      def composes(*commands)
        @container = Container.new(commands: commands)
      end

      def call(*args, **params)
        @container.call(args, params)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
neco-0.2.0 lib/neco/composition.rb
neco-0.1.0 lib/neco/composition.rb