Class: RequestHandler::IncludeOptionParser
Instance Method Summary
collapse
#initialize
Instance Method Details
#allowed_options(options) ⇒ Object
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/request_handler/include_option_parser.rb', line 15
def allowed_options(options)
options.map do |option|
option.gsub!(".", ::RequestHandler.configuration.separator)
begin
RequestHandler.configuration.validation_engine.validate!(option, allowed_options_type).output.to_sym
rescue Validation::Error
raise_error("OPTION_NOT_ALLOWED", "#{option} is not an allowed include option", OptionNotAllowedError)
end
end
end
|
#fetch_options ⇒ Object
26
27
28
29
|
# File 'lib/request_handler/include_option_parser.rb', line 26
def fetch_options
raise_error("INVALID_QUERY_PARAMETER", "must not be empty") if empty_param?("include")
params.fetch("include", "")
end
|
#run ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/request_handler/include_option_parser.rb', line 7
def run
return [] unless params.key?("include")
options = fetch_options
raise_error("INVALID_QUERY_PARAMETER", "must not contain a space") if options.include?(" ")
allowed_options(options.split(","))
end
|