Class: Salestation::Web::Extractors::ParamExtractor
- Inherits:
-
Object
- Object
- Salestation::Web::Extractors::ParamExtractor
- Includes:
- Deterministic
- Defined in:
- lib/salestation/web/extractors.rb
Class Method Summary collapse
Class Method Details
.[](*keys, coercions: {}, rack_key:) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/salestation/web/extractors.rb', line 67 def self.[](*keys, coercions: {}, rack_key:) InputExtractor.new do |rack_request| request_hash = rack_request.env[rack_key] || {} input = keys .select { |key| request_hash.key?(key.to_s) } .map { |key| [key, request_hash[key.to_s]] } .map { |key, value| coercions.key?(key) ? [key, coercions[key].call(value)] : [key, value] } .to_h Result::Success(input) end end |