Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/controllers/grape_swagger_rails/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ApplicationController < ActionController::Base
end

def index
run_before_index
end

private
Expand All @@ -15,5 +16,10 @@ def run_before_action
return unless GrapeSwaggerRails.options.before_action
instance_exec(request, &GrapeSwaggerRails.options.before_action)
end

def run_before_index
return unless GrapeSwaggerRails.options.before_index
instance_exec(request, &GrapeSwaggerRails.options.before_index)
end
end
end
9 changes: 9 additions & 0 deletions lib/grape-swagger-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def before_action(&block)
before_action_proc
end
end

def before_index(&block)
if block_given?
self.before_index_proc = block
else
before_index_proc
end
end
end

mattr_accessor :options
Expand All @@ -36,6 +44,7 @@ def before_action(&block)
supported_submit_methods: %w(get post put delete patch),

before_action_proc: nil, # Proc used as a controller before action
before_index_proc: nil, # Proc used as a controller before every index call

hide_url_input: false,
hide_api_key_input: false
Expand Down