Sha256: 7885a0545f60f275d48d9e4aff0f7c44cc5071b3666810f53edca8081e593cea

Contents?: true

Size: 678 Bytes

Versions: 14

Compression:

Stored size: 678 Bytes

Contents

module Urbanairship
  module Response
    module InstanceMethods
      attr_accessor :ua_response, :ua_options

      def code
        (ua_options[:code] || ua_response.code).to_s
      end

      def success?
        !!(code =~ /^2/)
      end
    end

    def self.wrap(response, options = {})
      if options[:body]
        output = options[:body]
      else
        begin
          output = JSON.parse(response.body || '{}')
        rescue JSON::ParserError
          output = {}
        end
      end

      output.extend(Urbanairship::Response::InstanceMethods)
      output.ua_response = response
      output.ua_options = options

      return output
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
urbanairship-2.3.3 lib/urbanairship/response.rb
urbanairship-2.3.2 lib/urbanairship/response.rb
urbanairship-2.3.1 lib/urbanairship/response.rb
urbanairship-2.3.0 lib/urbanairship/response.rb
urbanairship-2.2.4 lib/urbanairship/response.rb
urbanairship-2.2.3 lib/urbanairship/response.rb
urbanairship-2.2.2 lib/urbanairship/response.rb
urbanairship-2.2.1 lib/urbanairship/response.rb
urbanairship-2.2.0 lib/urbanairship/response.rb
urbanairship-2.1.2 lib/urbanairship/response.rb
urbanairship-2.1.1 lib/urbanairship/response.rb
sparqcode-urbanairship-2.0.0 lib/urbanairship/response.rb
urbanairship-2.1.0 lib/urbanairship/response.rb
urbanairship-2.0.0 lib/urbanairship/response.rb