def create_instance(res)
      response = res.parsed_response

      # if there was an error, throw it
      raise_error(response['error'], res.code) if response.nil? || response.key?('error')

      # There must be a top level entity
      # This is either one of payment, refund, or collection at present
      begin
        class_name = response['entity'].split('_').collect(&:capitalize).join

        klass = Razorpay.const_get class_name
      rescue NameError
        # Use Entity class if we don't find any
        klass = Razorpay::Entity
      end
      klass.new(response)
    end
def create_instance(res)
      response = res.parsed_response

      # if there was an error, throw it
      raise_error(response['error'], res.code) if response.nil? || response.key?('error')

      # There must be a top level entity
      # This is either one of payment, refund, or collection at present
      begin
        class_name = response['entity'].split('_').collect(&:capitalize).join

        klass = Razorpay.const_get class_name
      rescue NameError
        # Use Entity class if we don't find any
        klass = Razorpay::Entity
      end
      klass.new(response)
    end
def create_instance ( res ) response = res . parsed_response # if there was an error, throw it raise_error ( response [ 'error' ] , res . code ) if response . nil? || response . key? ( 'error' ) # There must be a top level entity # This is either one of payment, refund, or collection at present begin class_name = response [ 'entity' ] . split ( '_' ) . collect ( :capitalize ) . join klass = Razorpay . const_get class_name rescue NameError # Use Entity class if we don't find any klass = Razorpay :: Entity end klass . new ( response ) end
Recursively builds entity instances
 out of all hashes in the response object
Recursively builds entity instances out of all hashes in the response object