module Authority::UserAbilities

Public Instance Methods

can?(action, options = {}) click to toggle source
# File lib/authority/user_abilities.rb, line 20
def can?(action, options = {})
  self_and_maybe_options = [self, options].tap {|args| args.pop if args.last == {}}
  begin
    ApplicationAuthorizer.send("authorizes_to_#{action}?", *self_and_maybe_options)
  rescue NoMethodError => original_exception
    begin
      # For backwards compatibility
      response = ApplicationAuthorizer.send("can_#{action}?", *self_and_maybe_options)
      Authority.logger.warn(
        "DEPRECATION WARNING: Please rename `ApplicationAuthorizer.can_#{action}?` to `authorizes_to_#{action}?`"
      )
      response
    rescue NoMethodError => new_exception
      raise original_exception
    end
  end
end