class Pingdom::Base
Public Class Methods
attributes(hash)
click to toggle source
# File lib/pingdom/base.rb, line 10 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 40 def self.check_error!(response) if 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 4 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 48 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 32 def id @attributes[:id] end
inspect()
click to toggle source
# File lib/pingdom/base.rb, line 36 def inspect "#<%s %s>" % [self.class.to_s, @attributes.inject([]){ |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 24 def method_missing(name, *args, &block) @attributes[name] or super end
respond_to?(name)
click to toggle source
Calls superclass method
# File lib/pingdom/base.rb, line 28 def respond_to?(name) super(name) || @attributes.key?(name) end