Sha256: efb86a736194f53de8083272a1308cc800e13e3177e3ed8fc5292ef5ecabb821
Contents?: true
Size: 1.16 KB
Versions: 6
Compression:
Stored size: 1.16 KB
Contents
require 'surveymonkey/logging' ## # Object representing a SurveyMonkey API method. class Surveymonkey::API::Method attr_reader :path, :http_method, :method_name ## # Create a new method. Does some input validation to make sure the # associated HTTP method is valid. def initialize(path, http_method = 'post', method_name = 'UNSPECIFIED') begin $log.debug(sprintf("%s: enter", __method__)) # FIXME validate the path @path = path.to_s # store our short name @method_name = method_name.to_s # validate the method the_method = http_method.to_s.downcase $log.debug(sprintf("%s: the_method: '%s' (was '%s')", __method__, the_method, http_method)) if the_method =~ /^(get|post|patch|put|delete|move|copy|head|options)$/ @http_method = the_method $log.debug(sprintf("%s: method: %s", __method__, the_method)) else raise StandardError, "'#{the_method}' is not a valid HTTP method", caller end rescue StandardError => e $log.error(sprintf("%s: unable to initialize API method: %s", __method__, e.message)) raise end end def to_s self.method_name end end
Version data entries
6 entries across 6 versions & 1 rubygems