Class: OneApm::Support::RenameRulesEngine::Rule
- Inherits:
-
Object
- Object
- OneApm::Support::RenameRulesEngine::Rule
- Defined in:
- lib/one_apm/support/rename_rules_engine/external_rename_rule.rb
Constant Summary collapse
- OA_RENAME_SEPARATOR =
'/'.freeze
Instance Attribute Summary collapse
-
#ignore ⇒ Object
Returns the value of attribute ignore.
-
#match_expressions ⇒ Object
Returns the value of attribute match_expressions.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#rename_rules ⇒ Object
Returns the value of attribute rename_rules.
-
#replacement ⇒ Object
Returns the value of attribute replacement.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #apply(request) ⇒ Object
- #enable? ⇒ Boolean
-
#initialize(hash) ⇒ Rule
constructor
A new instance of Rule.
- #should_rename?(request) ⇒ Boolean
Constructor Details
#initialize(hash) ⇒ Rule
Returns a new instance of Rule.
56 57 58 59 60 61 62 63 |
# File 'lib/one_apm/support/rename_rules_engine/external_rename_rule.rb', line 56 def initialize(hash) @replacement = hash['replacement'] @state = hash['state'].to_i @ignore = hash['ignore'] @priority = hash['priority'].to_i @match_expressions = hash['match_expression'].map { |match_expression| MatchExpression::Engine.create_match_expression(match_expression) } @rename_rules = hash['rename'].map { |rename| Rename::Engine.create_rename_rules(rename) } end |
Instance Attribute Details
#ignore ⇒ Object
Returns the value of attribute ignore.
54 55 56 |
# File 'lib/one_apm/support/rename_rules_engine/external_rename_rule.rb', line 54 def ignore @ignore end |
#match_expressions ⇒ Object
Returns the value of attribute match_expressions.
54 55 56 |
# File 'lib/one_apm/support/rename_rules_engine/external_rename_rule.rb', line 54 def match_expressions @match_expressions end |
#priority ⇒ Object
Returns the value of attribute priority.
54 55 56 |
# File 'lib/one_apm/support/rename_rules_engine/external_rename_rule.rb', line 54 def priority @priority end |
#rename_rules ⇒ Object
Returns the value of attribute rename_rules.
54 55 56 |
# File 'lib/one_apm/support/rename_rules_engine/external_rename_rule.rb', line 54 def rename_rules @rename_rules end |
#replacement ⇒ Object
Returns the value of attribute replacement.
54 55 56 |
# File 'lib/one_apm/support/rename_rules_engine/external_rename_rule.rb', line 54 def replacement @replacement end |
#state ⇒ Object
Returns the value of attribute state.
54 55 56 |
# File 'lib/one_apm/support/rename_rules_engine/external_rename_rule.rb', line 54 def state @state end |
Instance Method Details
#apply(request) ⇒ Object
75 76 77 78 79 |
# File 'lib/one_apm/support/rename_rules_engine/external_rename_rule.rb', line 75 def apply(request) rename_rules.map do |rename_rule| rename_rule.segment(request) end.join(OA_RENAME_SEPARATOR) end |
#enable? ⇒ Boolean
71 72 73 |
# File 'lib/one_apm/support/rename_rules_engine/external_rename_rule.rb', line 71 def enable? !ignore && state == 0 end |
#should_rename?(request) ⇒ Boolean
65 66 67 68 69 |
# File 'lib/one_apm/support/rename_rules_engine/external_rename_rule.rb', line 65 def should_rename?(request) match_expressions.map do |match_expression| match_expression.match?(request) end.all? end |