Sha256: b3f7bd6dc040d529cd9f050734beb878292cc3a77540e33e58c756c4c051eee5
Contents?: true
Size: 822 Bytes
Versions: 1
Compression:
Stored size: 822 Bytes
Contents
module CleverReach class ResponseDecorator < SimpleDelegator def initialize(response) super @response = response end def valid? # Let's be flexible when checking for the status. answer_hash[:status] =~ /success/i end def status_code answer_hash[:statuscode].to_i end def to_hash data = answer_hash[:data] clean! data.dup end private # ---------------------------------------------- def response_hash_key @response.body.keys.find { |k| k.to_s =~ /_response$/ } end def answer_hash @response.body[response_hash_key][:return] end def clean!(hash) hash.reject! do |k,v| if v.is_a? Hash clean!(v); false else k.to_s =~ /^@/ end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clever_reach-0.0.1 | lib/clever_reach/response_decorator.rb |