lib/roda/plugins/typecast_params.rb
# Recursive method to get subkeys.
Recursive method to get subkeys.
Recursive method to get subkeys .
def subkey(keys, do_raise)
          unless key = keys.shift
            return self
          end
          reason = :invalid_type
          case key
          when String
            unless @obj.is_a?(Hash)
              raise Error, "parameter #{param_name(nil)} is not a hash" if do_raise
              return
            end
            present = !@obj[key].nil?
          when Integer
            unless @obj.is_a?(Array)
              raise Error, "parameter #{param_name(nil)} is not an array" if do_raise
              return
            end
            present = key < @obj.length
          else
            raise ProgrammerError, "invalid argument used to traverse parameters: #{key.inspect}"
          end
          unless present
            reason = :missing
            raise Error, "parameter #{param_name(key)} is not present" if do_raise
            return
          end
          self[key].subkey(keys, do_raise)
        rescue => e
          handle_error(key, reason, e)
        end
def subkey ( keys , do_raise ) unless key = keys . shift return self end reason = :invalid_type case key when String unless @obj . is_a? ( Hash ) raise Error , "parameter #{param_name(nil)} is not a hash" if do_raise return end present = ! @obj [ key ] . nil? when Integer unless @obj . is_a? ( Array ) raise Error , "parameter #{param_name(nil)} is not an array" if do_raise return end present = key < @obj . length else raise ProgrammerError , "invalid argument used to traverse parameters: #{key.inspect}" end unless present reason = :missing raise Error , "parameter #{param_name(key)} is not present" if do_raise return end self [ key ] . subkey ( keys , do_raise ) rescue => e handle_error ( key , reason , e ) end
Recursive method to get subkeys.
Recursive method to get subkeys .
keys
do_raise