class Qonfig::Settings::KeyGuard

@api private @since 0.2.0

Attributes

key[R]

@return [String, Symbol, Object]

@api private @sicne 0.2.0

Public Class Methods

new(key) click to toggle source

@param key [String, Symbol, Object]

@api private @since 0.2.0

# File lib/qonfig/settings/key_guard.rb, line 30
def initialize(key)
  @key = key
end
prevent_incomparabilities!(key) click to toggle source

@param key [String, Symbol, Object] @return [void]

@raise [Qonfig::ArgumentError] @raise [Qonfig::CoreMethodIntersectionError]

@api private @since 0.2.0

# File lib/qonfig/settings/key_guard.rb, line 15
def prevent_incomparabilities!(key)
  new(key).prevent_incomparabilities!
end

Public Instance Methods

prevent_core_method_intersection!() click to toggle source

@return [void]

@raise [Qonfig::CoreMethodIntersectionError]

@api private @since 0.2.0

# 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!() click to toggle source

@return [void]

@raise [Qonfig::ArgumentError] @raise [Qonfig::CoreMethodIntersectionError]

@api private @since 0.2.0

# 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!() click to toggle source

@return [void]

@raise [Qonfig::ArgumentError]

@api private @since 0.2.0

# 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