class ApiClient::Base

Public Class Methods

parse(response) click to toggle source
# File lib/api_client/base.rb, line 22
def parse(response)
  if response.is_a?(Faraday::Response)
    return nil if response.status == 204
    response = response.body
  end

  if self.format == :json
    MultiJson.load(response)
  elsif self.format == :xml
    MultiXml.parse(response)
  else
    response
  end
end
subkey_class() click to toggle source
# File lib/api_client/base.rb, line 18
def subkey_class
  Hashie::Mash
end

Public Instance Methods

id() click to toggle source
# File lib/api_client/base.rb, line 42
def id
  self['id']
end
inspect() click to toggle source
# File lib/api_client/base.rb, line 46
def inspect
  attributes = []
  attr_keys = self.keys - ['id']
  attributes.push "id: #{self.id}" if self.id
  attr_keys.each do |key|
    attributes.push("#{key}: #{self[key].inspect}")
  end
  "#<#{self.class} #{attributes.join(', ')}>"
end

Private Instance Methods

has_special_ending?(name) click to toggle source
# File lib/api_client/base.rb, line 73
def has_special_ending?(name)
  name.to_s =~ /[?=]$/
end
method_missing(method_name, *args, &blk) click to toggle source
Calls superclass method
# File lib/api_client/base.rb, line 57
def method_missing(method_name, *args, &blk)
  if respond_to?(method_name) || has_special_ending?(method_name)
    super
  elsif use_strict_reader?(method_name)
    fetch(method_name)
  else
    super
  end
end
use_strict_reader?(method_name) click to toggle source
# File lib/api_client/base.rb, line 67
def use_strict_reader?(method_name)
  respond_to?(:strict_attr_reader?) &&
    self.strict_attr_reader? &&
    method_name != :to_ary
end