Sha256: c1de716603e137921a275d49efdde027677e0220db9acf6ef2b3c2e100b34121

Contents?: true

Size: 979 Bytes

Versions: 1

Compression:

Stored size: 979 Bytes

Contents

module Democritus
  class ClassBuilder
    # @api public
    #
    # An abstract class useful in composing additional Democritus::Commands
    #
    # The expected interface for a Democritus::Command is as follows:
    #
    # * Its #initialize method must accept a :builder keyword (i.e. `#initialize`)
    # * It responds to #call and #call does not accept any parameters
    class Command
      # @api public
      #
      # @param builder [Democritus::ClassBuilder] The context in which we are leveraging this building command.
      def initialize(*, builder:)
        self.builder = builder
      end

      # @api public
      #
      # @abstract Subclass and override #call to implement
      def call
        fail(NotImplementedError, 'Method #call should be overriden in child classes')
      end

      # @api private
      def defer(options = {}, &block)
        builder.defer(options, &block)
      end

      private

      attr_accessor :builder
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
democritus-0.2.0 lib/democritus/class_builder/command.rb