Class: NewRelic::Agent::RulesEngine

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/new_relic/agent/rules_engine.rb

Defined Under Namespace

Classes: Rule

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rules = []) ⇒ RulesEngine

Returns a new instance of RulesEngine.



11
12
13
# File 'lib/new_relic/agent/rules_engine.rb', line 11

def initialize(rules=[])
  @rules = rules
end

Instance Attribute Details

#rulesObject

Returns the value of attribute rules.



9
10
11
# File 'lib/new_relic/agent/rules_engine.rb', line 9

def rules
  @rules
end

Instance Method Details

#rename(original_string) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/new_relic/agent/rules_engine.rb', line 15

def rename(original_string)
  @rules.sort.inject(original_string) do |string,rule|
    if rule.each_segment
      result, matched = rule.map_to_list(string.split('/'))
      result = result.join('/')
    else
      result, matched = rule.apply(string)
    end

    break result if matched && rule.terminate_chain
    result
  end
end