Class: SmartCore::Initializer::Type Private

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

Instance Method Summary collapse

Constructor Details

#initialize(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.

Parameters:

  • checker (Proc)

Since:

  • 0.5.0



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/smart_core/initializer/type.rb', line 18

def initialize(name, checker)
  unless name.is_a?(String) || name.is_a?(Symbol)
    raise(SmartCore::Initializer::ArgumentError, 'Type name should be a symbol or a string')
  end

  unless checker.is_a?(Proc)
    raise(SmartCore::Initializer::ArgumentError, 'Checker should be a proc')
  end

  @name = name.to_sym
  @checker = checker
end

Instance Attribute Details

#nameString (readonly)

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.

Returns:

  • (String)

Since:

  • 0.5.0



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

def name
  @name
end

Instance Method Details

#comparable?(value) ⇒ 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:

  • value (Any)

Returns:

  • (Boolean)

Raises:

Since:

  • 0.5.0



38
39
40
# File 'lib/smart_core/initializer/type.rb', line 38

def comparable?(value)
  checker.call(value)
end