Sha256: 6602eb5e72f47a2b81f8d61e5778a0c3bde048d31034c7dc5bedd414077f56a9
Contents?: true
Size: 940 Bytes
Versions: 2
Compression:
Stored size: 940 Bytes
Contents
# frozen_string_literal: true require 'request_handler/option_parser' require 'request_handler/error' module RequestHandler class IncludeOptionParser < OptionParser def run return [] unless params.key?('include') options = fetch_options raise ExternalArgumentError, include: 'must not contain a space' if options.include? ' ' allowed_options(options.split(',')) end def allowed_options(options) options.map do |option| option.gsub!('.', ::RequestHandler.separator) begin allowed_options_type&.call(option).to_sym rescue Dry::Types::ConstraintError raise OptionNotAllowedError, option.to_sym => 'is not an allowed include option' end end end def fetch_options raise ExternalArgumentError, include_options: 'query paramter must not be empty' if empty_param?('include') params.fetch('include') { '' } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
request_handler-0.9.1 | lib/request_handler/include_option_parser.rb |
request_handler-0.9.0 | lib/request_handler/include_option_parser.rb |