Class: Qonfig::Settings::KeyMatcher Private

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

Constant Summary collapse

SCOPE_SPLITTER =

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

Returns:

  • (String)

Since:

  • 0.13.0

'.'
MATCHER_SCOPE_SPLITTER =

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

Returns:

  • (String)

Since:

  • 0.13.0

'\.'
GENERIC_PART_PATTERN =

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

Returns:

  • (String)

Since:

  • 0.13.0

'*'
GENERIC_REGEXP_PATTERN =

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

Returns:

  • (String)

Since:

  • 0.13.0

'[^\.]+\.'
INFINITE_PART_PATTERN =

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

Returns:

  • (String)

Since:

  • 0.13.0

'#'
INFINITE_REGEXP_PATTERN =

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

Returns:

  • (String)

Since:

  • 0.13.0

'\.*.*'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope_pattern) ⇒ 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:

  • scope_pattern (String, Symbol)

Raises:

Since:

  • 0.13.0



55
56
57
58
59
60
61
62
# File 'lib/qonfig/settings/key_matcher.rb', line 55

def initialize(scope_pattern)
  scope_pattern = scope_pattern.to_s if scope_pattern.is_a?(Symbol)
  raise Qonfig::ArgumentError unless scope_pattern.is_a?(String)

  @scope_pattern      = scope_pattern.dup.freeze
  @scope_pattern_size = count_scope_pattern_size(scope_pattern)
  @pattern_matcher    = build_pattern_matcher(scope_pattern)
end

Instance Attribute Details

#scope_patternString (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.13.0



46
47
48
# File 'lib/qonfig/settings/key_matcher.rb', line 46

def scope_pattern
  @scope_pattern
end

Instance Method Details

#generic?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.

Returns:

  • (Boolean)

Since:

  • 0.21.0



68
69
70
# File 'lib/qonfig/settings/key_matcher.rb', line 68

def generic?
  scope_pattern == GENERIC_PART_PATTERN || scope_pattern == INFINITE_PART_PATTERN
end

#match?(setting_key_pattern) ⇒ 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:

  • setting_key_pattern (String)

Returns:

  • (Boolean)

Since:

  • 0.13.0



77
78
79
80
# File 'lib/qonfig/settings/key_matcher.rb', line 77

def match?(setting_key_pattern)
  return false unless comparable_event_scopes?(setting_key_pattern)
  !!pattern_matcher.match(setting_key_pattern)
end