Class: ApacheCrunch::ElementValueFetcher
- Inherits:
-
Object
- Object
- ApacheCrunch::ElementValueFetcher
- Defined in:
- lib/element_value_fetcher.rb
Overview
Finds a value from an Entry. Value may be directly from log or derived.
Instance Method Summary collapse
-
#dep_inject!(raw_value_fetcher_cls, derived_value_fetcher_cls) ⇒ Object
Handles dependency injection.
-
#fetch(entry, element_name) ⇒ Object
Returns the value of the element with the given name from the Entry instance.
-
#initialize ⇒ ElementValueFetcher
constructor
A new instance of ElementValueFetcher.
Constructor Details
#initialize ⇒ ElementValueFetcher
Returns a new instance of ElementValueFetcher.
4 5 6 7 |
# File 'lib/element_value_fetcher.rb', line 4 def initialize @_RawValueFetcher = RawValueFetcher @_DerivedValueFetcher = DerivedValueFetcher end |
Instance Method Details
#dep_inject!(raw_value_fetcher_cls, derived_value_fetcher_cls) ⇒ Object
Handles dependency injection
10 11 12 13 |
# File 'lib/element_value_fetcher.rb', line 10 def dep_inject!(raw_value_fetcher_cls, derived_value_fetcher_cls) @_RawValueFetcher = raw_value_fetcher_cls @_DerivedValueFetcher = derived_value_fetcher_cls end |
#fetch(entry, element_name) ⇒ Object
Returns the value of the element with the given name from the Entry instance.
So element_name might be :minute or :reqheader_firstline for instance.
18 19 20 21 22 23 24 25 26 |
# File 'lib/element_value_fetcher.rb', line 18 def fetch(entry, element_name) v = @_RawValueFetcher.new.fetch(entry, element_name) return v unless v.nil? v = @_DerivedValueFetcher.new.fetch(entry, element_name) return v unless v.nil? nil end |