module DutyFree::Rails::Controller
Extensions
to rails controllers. Provides convenient ways to pass certain information to the model layer, with `controller_info` and `whodunnit`. Also includes a convenient on/off switch, `duty_free_enabled_for_controller`.
Public Class Methods
included(controller)
click to toggle source
# File lib/duty_free/frameworks/rails/controller.rb, line 10 def self.included(controller) controller.before_action( :set_duty_free_enabled_for_controller, :set_duty_free_controller_info ) end
Protected Instance Methods
user_for_duty_free()
click to toggle source
Returns the user who is responsible for any changes that occur. By default this calls `current_user` and returns the result.
Override this method in your controller to call a different method, e.g. `current_person`, or anything you like.
@api public
# File lib/duty_free/frameworks/rails/controller.rb, line 26 def user_for_duty_free return unless defined?(current_user) ActiveSupport::VERSION::MAJOR >= 4 ? current_user.try!(:id) : current_user.try(:id) rescue NoMethodError current_user end