Sha256: 817f263791075b788b65f15ef90e02a7c827cda3f58071defa1b068d5263406a
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module Fear module ExtractorApi # Allows to pattern match and extract matcher variables # # @param pattern [String] # @return [Extractor::Pattern] # @note it is not intended to be used by itself, rather then with partial functions def [](pattern) Extractor::Pattern.new(pattern) end # Register extractor for given class # @!method register_extractor(*names, extractor) # @param names [<Class, String>, Class, String] name of a class. You can also pass alias for the name # @param extractor [Proc<any => Fear::Option>] proc taking any argument and returned Option # of extracted value('s) # # @example # register_extractor(Fear::Some, Fear.case(Fear::Some) { |some| some.get }.lift) # # register_extractor(User, Fear.case(User) { |user|} [user.id, user.email] , ) # # @example registering an alias. Alias should be CamelCased string # register_extractor(Fear::Some, 'Some', Fear.case(Fear::Some) { |some| some.get }.lift) # # # no you can extract Fear::Some's using Some alias # m.case(Fear['Some(value : Integer)']) { |value:| value * 2 } # def register_extractor(*args) Extractor.register_extractor(*args) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fear-1.2.0 | lib/fear/extractor_api.rb |
fear-1.1.0 | lib/fear/extractor_api.rb |