Class: Qonfig::Settings::KeyGuard Private

Inherits:
Object
  • Object
show all
Defined in:
lib/qonfig/settings/key_guard.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.2.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ KeyGuard

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 a new instance of KeyGuard.

Parameters:

  • key (String, Symbol, Object)

Since:

  • 0.2.0



30
31
32
# File 'lib/qonfig/settings/key_guard.rb', line 30

def initialize(key)
  @key = key
end

Instance Attribute Details

#keyString, ... (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, Symbol, Object)

Since:

  • 0.2.0



24
25
26
# File 'lib/qonfig/settings/key_guard.rb', line 24

def key
  @key
end

Class Method Details

.prevent_incomparabilities!(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, Object)

Raises:

Since:

  • 0.2.0



15
16
17
# File 'lib/qonfig/settings/key_guard.rb', line 15

def prevent_incomparabilities!(key)
  new(key).prevent_incomparabilities!
end

Instance Method Details

#prevent_core_method_intersection!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.

Raises:

Since:

  • 0.2.0



65
66
67
68
69
70
# File 'lib/qonfig/settings/key_guard.rb', line 65

def prevent_core_method_intersection!
  raise(
    Qonfig::CoreMethodIntersectionError,
    "<#{key}> key can not be used since this is a private core method"
  ) if Qonfig::Settings::CORE_METHODS.include?(key.to_s)
end

#prevent_incomparabilities!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.



41
42
43
44
# File 'lib/qonfig/settings/key_guard.rb', line 41

def prevent_incomparabilities!
  prevent_incompatible_key_type!
  prevent_core_method_intersection!
end

#prevent_incompatible_key_type!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.

Raises:

Since:

  • 0.2.0



52
53
54
55
56
57
# File 'lib/qonfig/settings/key_guard.rb', line 52

def prevent_incompatible_key_type!
  raise(
    Qonfig::ArgumentError,
    'Setting key should be a symbol or a string!'
  ) unless key.is_a?(Symbol) || key.is_a?(String)
end