module Safettp::Client
Attributes
base_url[R]
options_hash[R]
Public Class Methods
included(base)
click to toggle source
# File lib/safettp/client.rb, line 48 def self.included(base) base.extend(ClassMethods) %i[get post put patch delete].each do |method| define_method(method) do |uri_suffix, options = {}, &block| perform(method, uri_suffix, options, &block) end end end
new(base_url = self.class.config.base_url, options_hash = self.class.config.default_options)
click to toggle source
# File lib/safettp/client.rb, line 4 def initialize(base_url = self.class.config.base_url, options_hash = self.class.config.default_options) @base_url = base_url @options_hash = options_hash end
Public Instance Methods
perform(*args) { |guard| ... }
click to toggle source
# File lib/safettp/client.rb, line 10 def perform(*args, &block) response = perform_without_guard(*args) guard = Safettp::Guard.new(response) yield(guard) guard.evaluate! end
perform_without_guard(method, uri_suffix = '/', options = {})
click to toggle source
# File lib/safettp/client.rb, line 17 def perform_without_guard(method, uri_suffix = '/', options = {}) url = "#{base_url}#{uri_suffix}" Safettp::Request.new(url, options_hash.merge(options)) .perform(method) end