Class: RequestHandler::IncludeOptionParser
Instance Method Summary
collapse
#initialize
Instance Method Details
#allowed_options(options) ⇒ Object
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/request_handler/include_option_parser.rb', line 14
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
|
#fetch_options ⇒ Object
25
26
27
28
|
# File 'lib/request_handler/include_option_parser.rb', line 25
def fetch_options
raise IncludeParamsError, include_options: 'query paramter must not be empty' if empty_param?('include')
params.fetch('include') { '' }
end
|
#run ⇒ Object
7
8
9
10
11
12
|
# File 'lib/request_handler/include_option_parser.rb', line 7
def run
return [] unless params.key?('include')
options = fetch_options
raise IncludeParamsError, include: 'must not contain a space' if options.include? ' '
allowed_options(options.split(','))
end
|