Class: Dry::Types::FnContainer Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/types/fn_container.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Internal container for constructor functions used by the built-in types

Class Method Summary collapse

Class Method Details

.[](fn_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
26
27
28
29
# File 'lib/dry/types/fn_container.rb', line 23

def self.[](fn_name)
  if container.key?(fn_name)
    container[fn_name]
  else
    fn_name
  end
end

.containerObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/dry/types/fn_container.rb', line 10

def self.container
  @container ||= Container.new
end

.register(function = Dry::Core::Constants::Undefined, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
18
19
20
# File 'lib/dry/types/fn_container.rb', line 15

def self.register(function = Dry::Core::Constants::Undefined, &block)
  fn = Dry::Core::Constants::Undefined.default(function, block)
  fn_name = register_name(fn)
  container.register(fn_name, fn) unless container.key?(fn_name)
  fn_name
end

.register_name(function) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
# File 'lib/dry/types/fn_container.rb', line 32

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