A generic authorization query. This is what will be called programatically,
since the actual permission methods can't be guaranteed to exist. And
because we want to intelligently combine multiple applicable methods.
options should be a CRUD verb (:create,
:read, :update, :destroy) options should be
the name of a model attribute options is the
name of a method
def authorized_for?(options = {})
raise ArgumentError, "unknown crud type #{options[:crud_type]}" if options[:crud_type] and ![:create, :read, :update, :delete].include?(options[:crud_type])
methods = cached_authorized_for_methods(options)
return ActiveRecordPermissions.default_permission if methods.empty?
return send(methods.first) if methods.one?
return false if methods.any? {|m| !send(m)}
true
end