Sha256: f15681279936793d1c59908732bc1fd8b3baf03127252541f58b84a501682cd3
Contents?: true
Size: 861 Bytes
Versions: 5
Compression:
Stored size: 861 Bytes
Contents
module Adhoq module AuthorizationMethods extend ActiveSupport::Concern included do |controller| controller.before_filter Authorizer.new helper_method :adhoq_current_user hide_action :adhoq_current_user end class Authorizer def before(controller) return true if authorization.call(controller) if failure = Adhoq.config.authorization_failure_action failure.call(controller) else controller.send(:render, text: 'No such file or directory', status: :not_found) end end private def authorization @authorization ||= Adhoq.config.callablize(:authorization) end end def adhoq_current_user @_adhoq_current_user_proc ||= Adhoq.config.callablize(:current_user) @_adhoq_current_user_proc.call(self) end end end
Version data entries
5 entries across 5 versions & 1 rubygems