intridea/grape — pull request #251 by simulacre (2012-09-27 06:42:36+00:00)
Title: changes: nested namespaces enforce their and parent validations; adds HashStack#gather

adds test for nested namesapces and params/validators

HashStack#gather provides all values for a given key

When Endpoint#run is called it will gather all :validations, not just
the closest one, and evaluate each one.

resource :machine do
params do
requires :serial, :existing_machine_serial => true, :desc => "The machine's serial number, e.g. 965ACD"
end
namespace 'serial' do
# The custom ExistingMachineSerial validator will be called and enforced
get do
Machine.find(:serial => params[:serial]).first
end
namespace 'power' do
# The custom ExistingMachineSerial validator will also be called and enforced
get do
Machine.find(:serial => params[:serial]).first.power_status
end
end
end
end