app/controllers/instance_configuration_controller.rb
# converts string to given (non-complex) type
# raises TypeError on failure
converts string to given (non-complex) type
raises TypeError on failure
converts string to given ( non - complex ) type raises TypeError on failure
def convert_value(str, type)
    if [TrueClass, FalseClass].include?(type)
      if str == 'true'
        return true
      elsif str == 'false'
        return false
      else
        raise TypeError, 'expected boolean'
      end
    elsif type == String
      return str
    elsif type == Symbol
      return str
    elsif type == Fixnum
      raise TypeError, 'expected integer' unless str =~ /^[-+]?[0-9]+$/
      return str.to_i
    elsif type == Float
      begin
        return Float(str)
      rescue ArgumentError
        raise TypeError, 'expected float'
      end
    else
      raise TypeError, "unsupported type: #{type}"
    end
  end
def convert_value ( str , type ) if [ TrueClass , FalseClass ] . include? ( type ) if str == 'true' return true elsif str == 'false' return false else raise TypeError , 'expected boolean' end elsif type == String return str elsif type == Symbol return str elsif type == Fixnum raise TypeError , 'expected integer' unless str =~ / ^[-+]?[0-9]+$ / return str . to_i elsif type == Float begin return Float ( str ) rescue ArgumentError raise TypeError , 'expected float' end else raise TypeError , "unsupported type: #{type}" end end
converts string to given (non-complex) type
raises TypeError on failure
converts string to given ( non - complex ) type raises TypeError on failure
str
<not_specific>
type
<not_specific>