Module: Fear::Extractor Private
- Defined in:
- lib/fear/extractor.rb,
lib/fear/extractor/grammar.rb,
lib/fear/extractor/matcher.rb,
lib/fear/extractor/pattern.rb,
lib/fear/extractor/any_matcher.rb,
lib/fear/extractor/matcher/and.rb,
lib/fear/extractor/array_matcher.rb,
lib/fear/extractor/value_matcher.rb,
lib/fear/extractor/extractor_matcher.rb,
lib/fear/extractor/array_head_matcher.rb,
lib/fear/extractor/empty_list_matcher.rb,
lib/fear/extractor/identifier_matcher.rb,
lib/fear/extractor/array_splat_matcher.rb,
lib/fear/extractor/typed_identifier_matcher.rb,
lib/fear/extractor/named_array_splat_matcher.rb,
lib/fear/extractor/anonymous_array_splat_matcher.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Modules: Grammar Classes: AnonymousArraySplatMatcher, AnyMatcher, ArrayHeadMatcher, ArrayMatcher, ArraySplatMatcher, EmptyListMatcher, ExtractorMatcher, IdentifierMatcher, Matcher, NamedArraySplatMatcher, Pattern, TypedIdentifierMatcher, ValueMatcher
Constant Summary collapse
- ExtractorNotFound =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Class.new(Error)
- BUILD_EXTRACTOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
proc do |key, extractor| Fear.matcher do |m| case key when String m.case(Module, ->(lookup) { lookup.to_s == key }) { extractor } m.case(String, key) { extractor } when Module m.case(Module, ->(lookup) { lookup <= key }) { extractor } m.case(String, key.to_s) { extractor } else m.case(key) { extractor } # may it be useful to register other types of keys? lambda? end end end
Class Method Summary collapse
- .find_extractor(klass) ⇒ Object private
-
.register_extractor(*names, extractor) ⇒ Object
private
Register extractor for given class.
Class Method Details
.find_extractor(klass) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 |
# File 'lib/fear/extractor.rb', line 39 def find_extractor(klass) @registry.call_or_else(klass, &EXTRACTOR_NOT_FOUND) end |
.register_extractor(*names, extractor) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Register extractor for given class
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fear/extractor.rb', line 60 def register_extractor(*args) *keys, extractor = *args @mutex.synchronize do keys.uniq.each do |key| @registry = BUILD_EXTRACTOR.(key, extractor).or_else(@registry) end end self end |