class Pingdom::Base

Public Class Methods

attributes(hash) click to toggle source
# File lib/pingdom/base.rb, line 9
    def self.attributes(hash)
      hash.each do |(attribute, aliases)|
        class_eval <<-"end;" unless instance_methods.include?(attribute.to_s)
          def #{attribute}
            @attributes["#{attribute}"]
          end
        end;

        Array.wrap(aliases).each do |aliased|
          alias_method aliased, attribute
        end
      end
    end
check_error!(response) click to toggle source
# File lib/pingdom/base.rb, line 43
def self.check_error!(response)
  if response.body.is_a?(String)
    raise Error, response.body
  elsif response.body.key?("error")
    raise Error, "%s (%s %s)" % [response.body["error"]["errormessage"],
                                 response.body["error"]["statuscode"],
                                 response.body["error"]["statusdesc"]]
  end
end
new(client, response, attributes = {}) click to toggle source
# File lib/pingdom/base.rb, line 3
def initialize(client, response, attributes = {})
  @client = client
  @response = response
  @attributes = attributes
end
parse(_client, response) click to toggle source
# File lib/pingdom/base.rb, line 53
def self.parse(_client, response)
  check_error!(response)
  response.body
end

Public Instance Methods

id() click to toggle source
# File lib/pingdom/base.rb, line 35
def id
  @attributes["id"]
end
inspect() click to toggle source
# File lib/pingdom/base.rb, line 39
def inspect
  "#<%s %s>" % [self.class.to_s, @attributes.reduce([]) { |a, (k, v)| a << "%s: %s" % [k, v.inspect]; a }.join(" ")]
end
method_missing(name, *args, &block) click to toggle source
Calls superclass method
# File lib/pingdom/base.rb, line 23
def method_missing(name, *args, &block)
  @attributes[name.to_s] || super
end
respond_to?(name) click to toggle source
Calls superclass method
# File lib/pingdom/base.rb, line 31
def respond_to?(name)
  super(name) || @attributes.key?(name.to_s)
end
respond_to_missing?(name, include_private = false) click to toggle source
Calls superclass method
# File lib/pingdom/base.rb, line 27
def respond_to_missing?(name, include_private = false)
  @attributes.key?(name.to_s) || super
end