Base class for all response from gliffy

Methods
F
M
N
V
Attributes
[R] body
Class Public methods
from_http_response(response,error_callback=nil)

Factory for creating actual response subclasses. This takes the results of HTTParty’s response, which is a hash, essentially. This assumes that any checks for validity have been done.

error_response
Set this to a Proc to handle errors if you don’t want the default behavior. The proc will get two arguments:
response
the raw response received (may be nil)
exception
One of NoResponseException, BadResponseException, or RequestFailedException. The message of that exception is a usable message if you want to ignore the exception
# File lib/gliffy/response.rb, line 65
    def self.from_http_response(response,error_callback=nil)
      verify(response,error_callback)
      root = response['response']
      klass = nil
      root.keys.each do |key|
        klassname = to_classname(key)
        begin
          this_klass = Gliffy.const_get(klassname)
        rescue NameError
          this_klass = nil
        end
        klass = this_klass unless this_klass.nil?
      end
      return Response.new(response.body) if !klass
      return klass.from_http_response(root)
    end
new(params)
# File lib/gliffy/response.rb, line 99
    def initialize(params)
      @params = params
    end
verify(response,error_callback)

Verifies that the response represents success, calling the error callback if it doesn’t

# File lib/gliffy/response.rb, line 84
    def self.verify(response,error_callback)
      error_callback = @@error_callback if error_callback.nil?
      return error_callback.call(response,NoResponseException.new('No response received at all')) if response.nil? 
      return error_callback.call(response,BadResponseException.new('Not a Gliffy response')) if !response['response']
      return error_callback.call(response,BadResponseException.new('No indication of success from Gliffy')) if !response['response']['success']
      if response['response']['success'] != 'true'
        error = response['response']['error']
        return error_callback.call(response,RequestFailedException.new('Request failed but no error inside response')) if !error
        return error_callback.call(response,RequestFailedException.new(error))
      end
    end
Instance Public methods
method_missing(symbol,*args)

Implements access to the object information. Parameters should be typed appropriately. The names are those as defined by the Gliffy XSD, save for dashes are replaced with underscores.

# File lib/gliffy/response.rb, line 107
    def method_missing(symbol,*args)
      if args.length == 0
        @params[symbol]
      else
        super(symbol,args)
      end
    end