Class: Flare::HttpMetricsConfig::HostConfig
- Inherits:
-
Object
- Object
- Flare::HttpMetricsConfig::HostConfig
- Defined in:
- lib/flare/http_metrics_config.rb
Instance Attribute Summary collapse
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
-
#all ⇒ Object
Track all paths for this host (normalized via normalize_path).
- #all? ⇒ Boolean
-
#allow(pattern) ⇒ Object
Track paths matching this regex (normalized via normalize_path).
-
#initialize ⇒ HostConfig
constructor
A new instance of HostConfig.
- #initialize_copy(source) ⇒ Object
-
#map(pattern, replacement) ⇒ Object
Track paths matching this regex with a custom replacement string.
-
#resolve(path) ⇒ Object
Returns the resolved path for a given raw path, or “*” if no match.
Constructor Details
#initialize ⇒ HostConfig
Returns a new instance of HostConfig.
8 9 10 11 |
# File 'lib/flare/http_metrics_config.rb', line 8 def initialize @rules = [] @all = false end |
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
6 7 8 |
# File 'lib/flare/http_metrics_config.rb', line 6 def rules @rules end |
Instance Method Details
#all ⇒ Object
Track all paths for this host (normalized via normalize_path)
22 23 24 |
# File 'lib/flare/http_metrics_config.rb', line 22 def all @all = true end |
#all? ⇒ Boolean
17 18 19 |
# File 'lib/flare/http_metrics_config.rb', line 17 def all? @all end |
#allow(pattern) ⇒ Object
Track paths matching this regex (normalized via normalize_path)
27 28 29 |
# File 'lib/flare/http_metrics_config.rb', line 27 def allow(pattern) @rules << {pattern: pattern, replacement: nil} end |
#initialize_copy(source) ⇒ Object
13 14 15 |
# File 'lib/flare/http_metrics_config.rb', line 13 def initialize_copy(source) @rules = source.rules.dup end |
#map(pattern, replacement) ⇒ Object
Track paths matching this regex with a custom replacement string
32 33 34 |
# File 'lib/flare/http_metrics_config.rb', line 32 def map(pattern, replacement) @rules << {pattern: pattern, replacement: replacement} end |
#resolve(path) ⇒ Object
Returns the resolved path for a given raw path, or “*” if no match. If :all, returns nil to signal “use normalize_path”. If a rule matches with a replacement, returns the replacement. If a rule matches without a replacement, returns nil to signal “use normalize_path”. If no rules match, returns “*”.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/flare/http_metrics_config.rb', line 41 def resolve(path) return nil if @all @rules.each do |rule| if rule[:pattern].match?(path) return rule[:replacement] # nil means use normalize_path end end "*" end |