Module: SmartCore::Schema::KeyControl Private

Defined in:
lib/smart_core/schema/key_control.rb

Overview

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

Since:

  • 0.1.0

Class Method Summary collapse

Class Method Details

.normalize(key) ⇒ String

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:

  • key (String, Symbol)

Returns:

  • (String)

Since:

  • 0.1.0



12
13
14
15
# File 'lib/smart_core/schema/key_control.rb', line 12

def normalize(key)
  prevent_incompatible!(key)
  key.to_s
end

.normalize_list(keys) ⇒ Array<String>

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:

  • keys (Array<String,Symbol>)

Returns:

  • (Array<String>)

Since:

  • 0.1.0



22
23
24
# File 'lib/smart_core/schema/key_control.rb', line 22

def normalize_list(keys)
  keys.map { |key| normalize(key) }
end

.prevent_incompatible!(key) ⇒ 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:

  • key (String, Symbol)

Since:

  • 0.1.0



31
32
33
34
35
36
37
# File 'lib/smart_core/schema/key_control.rb', line 31

def prevent_incompatible!(key)
  unless key.is_a?(String) || key.is_a?(Symbol)
    raise(SmartCore::Schema::ArgumentError, <<~ERROR_MESSAGE)
      Schema keys should be a type of string or symbol
    ERROR_MESSAGE
  end
end