lib/slack/web/api/templates/method.erb in slack-ruby-client-2.3.0 vs lib/slack/web/api/templates/method.erb in slack-ruby-client-2.4.0
- old
+ new
@@ -36,9 +36,10 @@
def <%= group.gsub(".", "_") %>_<%= name %>(options = {})
<% data['args'].select{ |k, v| v['required'] }.each do |arg_name, arg_v| %>
raise ArgumentError, 'Required arguments :<%= arg_name %> missing' if options[:<%= arg_name %>].nil?
<% end %>
<% data['arg_groups']&.each do |arg_group| %>
+ <% next if arg_group['args'].size <= 1 %>
<% arg_string = arg_group['args'].map { |arg_name| ":#{arg_name}" }.join(', ') %>
<% if arg_group['mutually_exclusive'] %>
raise ArgumentError, 'Exactly one of <%= arg_string %> is required' unless <%= arg_group['args'].map { |arg_name| "options[:#{arg_name}].nil?" }.join(' ^ ') %>
<% else %>
raise ArgumentError, 'At least one of <%= arg_string %> is required' if <%= arg_group['args'].map { |arg_name| "options[:#{arg_name}].nil?"}.join(' && ') %>