+ module InstanceMethods
+ # choose template based on opts[:for_user]
+ def as_api_response(template=nil, opts={})
+ if template.nil?
+ user = opts[:for_user] || current_user
+ if user.andand.is_admin and self.respond_to? :api_accessible_superuser
+ template = :superuser
+ else
+ template = :user
+ end
+ end
+ self.as_api_response_orig(template, opts)
+ end
+ end
+