lib/azeroth/request_handler.rb in azeroth-0.2.0 vs lib/azeroth/request_handler.rb in azeroth-0.3.0
- old
+ new
@@ -32,14 +32,15 @@
#
# @return [String]
def process
return unless json?
- json = model.decorate(resource)
+ json = model.decorate(resource)
+ response_status = status
controller.instance_eval do
- render(json: json)
+ render(json: json, status: response_status)
end
end
private
@@ -86,8 +87,22 @@
#
# @return [Object]
# @raise Not implmented
def resource
raise 'must be implemented in subclass'
+ end
+
+ # @private
+ #
+ # Response status
+ #
+ # For most requests, status is 200 (+:ok+)
+ #
+ # Must be implemented in subclasses that will handle
+ # status differently
+ #
+ # @return [Symbol]
+ def status
+ :ok
end
end
end