Class: Omnis::NestedHashExtractor
- Inherits:
-
Object
- Object
- Omnis::NestedHashExtractor
- Defined in:
- lib/omnis/nested_hash_extractor.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#extractor(path) ⇒ Object
returns a lambda which extracts a value from a nested hash.
Instance Method Details
#extractor(path) ⇒ Object
returns a lambda which extracts a value from a nested hash
4 5 6 7 8 |
# File 'lib/omnis/nested_hash_extractor.rb', line 4 def extractor(path) raise ArgumentError("path to extract must be a string") unless String === path expr = "source#{from_dot_path(path)} rescue nil" ->source { eval(expr) } end |