Sha256: e70638504d17717902cb25bcef6b5ddc2c6664bd7bbeb901ef141912e3ace8f0

Contents?: true

Size: 546 Bytes

Versions: 1

Compression:

Stored size: 546 Bytes

Contents

# frozen_string_literal: true

require "addressable/uri"

module ActiveWebhook
  module Formatting
    class URLEncodedAdapter < BaseAdapter
      protected

      def self.compact(h)
        h.delete_if { |k, v|
          v = compact(v) if v.respond_to?(:each)
          v.nil? || v.empty?
        }
      end

      def content_type
        "application/x-www-form-urlencoded"
      end

      def encoded_data
        uri = Addressable::URI.new
        uri.query_values = self.class.compact(data)
        uri.query
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_webhook-1.0.0 lib/active_webhook/formatting/url_encoded_adapter.rb