module AuthorizeAction

Public Class Methods

included(base) click to toggle source
# File lib/authorize_action.rb, line 14
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

authorize_action!() click to toggle source
# File lib/authorize_action.rb, line 5
def authorize_action!
  authorization_rule = self.class.authorization_rules && self.class.authorization_rules[current_action_name]
  action_permitted = case authorization_rule 
                     when Proc then instance_exec(&authorization_rule)
                     when Symbol then send(authorization_rule)
                     end
  forbid_action! unless action_permitted
end

Private Instance Methods

current_action_name() click to toggle source
# File lib/authorize_action.rb, line 28
def current_action_name
  raise NotImplementedError
end
forbid_action!() click to toggle source
# File lib/authorize_action.rb, line 24
def forbid_action!
  raise NotImplementedError
end