Sha256: 4febae470295a5a16e20725801c0cbb5c4d8de174720fd0a60a667e2e32dba3c

Contents?: true

Size: 747 Bytes

Versions: 6

Compression:

Stored size: 747 Bytes

Contents

require 'dry/types/container'

module Dry
  module Types
    class FnContainer
      # @api private
      def self.container
        @container ||= Container.new
      end

      # @api private
      def self.register(function)
        register_function_name = register_name(function)
        container.register(register_function_name, function) unless container.key?(register_function_name)
        register_function_name
      end

      # @api private
      def self.[](function_name)
        if container.key?(function_name)
          container[function_name]
        else
          function_name
        end
      end

      # @api private
      def self.register_name(function)
        "fn_#{function.object_id}"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dry-types-0.12.3 lib/dry/types/fn_container.rb
dry-types-0.12.2 lib/dry/types/fn_container.rb
dry-types-0.12.1 lib/dry/types/fn_container.rb
dry-types-0.12.0 lib/dry/types/fn_container.rb
dry-types-0.11.1 lib/dry/types/fn_container.rb
dry-types-0.11.0 lib/dry/types/fn_container.rb