class ApacheCrunch::DerivedValueFetcher
Returns the value of an element derived from one captured directly from the log.
Public Class Methods
new()
click to toggle source
# File lib/element_value_fetcher.rb, line 46 def initialize @_DerivationRuleFinder = DerivationRuleFinder end
Public Instance Methods
dep_inject!(derivation_rule_finder_cls)
click to toggle source
Handles dependency injection
# File lib/element_value_fetcher.rb, line 51 def dep_inject!(derivation_rule_finder_cls) @_DerivationRuleFinder = derivation_rule_finder_cls end
fetch(entry, element_name)
click to toggle source
Returns the value for the given name by deriving from an Element
in the Entry
.
Returns nil if no such value can be derived.
# File lib/element_value_fetcher.rb, line 58 def fetch(entry, element_name) # Find the derivation rule that will get us the element we want rule = @_DerivationRuleFinder.find(element_name) return nil if rule.nil? # Get the value of the element from which we're deriving source_element_name = rule.source_name source_element = entry.captured_elements[source_element_name] return nil if source_element.nil? # Do the derivation rule.derive(element_name, source_element.value) end