Sha256: 988ce36099fae65d1a624ee66f7006329591fc8c7a6f030e3b8cce92d7832c67

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

module Substation
  class Environment

    # The DSL class used to define register processors
    class DSL

      # The registry of processors
      #
      # @return [Hash<Symbol, #call>]
      #
      # @api private
      attr_reader :registry


      # The registry of processors
      #
      # @param [Proc] block
      #   a block to be instance_eval'ed
      #
      # @return [Hash<Symbol, #call>]
      #
      # @api private
      def self.registry(&block)
        new(&block).registry
      end

      # Initialize a new instance
      #
      # @param [Proc] block
      #   a block to be instance_eval'ed
      #
      # @return [undefined]
      #
      # @api private
      def initialize(&block)
        @registry = {}
        instance_eval(&block) if block
      end

      # Register a new +processor+ using the given +name+
      #
      # @param [#to_sym] name
      #   the name to register the +processor+ for
      #
      # @param [#call] processor
      #   the processor to register for +name+
      #
      # @return [self]
      #
      # @api private
      def register(name, processor)
        @registry[name] = processor
        self
      end

    end # class DSL
  end # class Environment
end # module Substation

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
substation-0.0.10.beta2 lib/substation/environment/dsl.rb
substation-0.0.8 lib/substation/environment/dsl.rb