Created
October 9, 2015 05:08
-
-
Save timoschilling/c35b3eee7022e87c8027 to your computer and use it in GitHub Desktop.
Trailblazer::WithCurrentUser maps you the current_user in your Trb params hash, this is just a idea and not save for work!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
include Trailblazer::Operation::Controller | |
include Trailblazer::WithCurrentUser | |
self.trb_with_current_user_param_key = :current_user | |
self.trb_with_current_user_method = :current_user | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Trailblazer::WithCurrentUser | |
[:form, :present, :collection, :run, :respond].each do |method| | |
define_method method do |*args, &block| | |
options = args.extract_options! | |
options[:params][trb_with_current_user_param_key] = send(trb_with_current_user_method) | |
args << options | |
super *args, &block | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment