Class: SmartCore::Initializer::TypeSet Private

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_core/initializer/type_set.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.

Since:

  • 0.5.0

Instance Method Summary collapse

Constructor Details

#initializevoid

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.

Since:

  • 0.5.0



10
11
12
# File 'lib/smart_core/initializer/type_set.rb', line 10

def initialize
  @types = {}
end

Instance Method Details

#has_type?(name) ⇒ Boolean

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.

Parameters:

  • name (String, Symbol)

Returns:

  • (Boolean)

Since:

  • 0.5.0



19
20
21
# File 'lib/smart_core/initializer/type_set.rb', line 19

def has_type?(name)
  types.key?(name)
end

#register(name, checker) ⇒ void

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.

This method returns an undefined value.

Parameters:

  • name (String, Symbol)
  • checker (Proc)

Since:

  • 0.5.0



29
30
31
32
# File 'lib/smart_core/initializer/type_set.rb', line 29

def register(name, checker)
  type = SmartCore::Initializer::Type.new(name, checker)
  types[type.name] = type
end

#resolve(name) ⇒ SmartCore::Initializer::Type

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.

Parameters:

  • name (String, Symbol)

Returns:

Since:

  • 0.5.0



39
40
41
42
43
# File 'lib/smart_core/initializer/type_set.rb', line 39

def resolve(name)
  types.fetch(name.to_sym)
rescue KeyError
  raise SmartCore::Initializer::UnregisteredTypeError, "type :#{name} is not registered!"
end