Class: RequestHandler::IncludeOptionHandler
Instance Method Summary
collapse
#initialize
Instance Method Details
#allowed_options(options) ⇒ Object
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/request_handler/include_option_handler.rb', line 13
def allowed_options(options)
options.map do |option|
begin
allowed_options_type&.call(option)
rescue Dry::Types::ConstraintError
raise OptionNotAllowedError, option.to_sym => 'is not an allowed include option'
end
option.to_sym
end
end
|
#fetch_options ⇒ Object
24
25
26
27
|
# File 'lib/request_handler/include_option_handler.rb', line 24
def fetch_options
raise ExternalArgumentError, include_options: 'query paramter must not be empty' if empty_param?('include')
params.fetch('include') { '' }
end
|
#run ⇒ Object
6
7
8
9
10
11
|
# File 'lib/request_handler/include_option_handler.rb', line 6
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
|