Sha256: 9356028f2779da1e3233325ddfc457a0bc7a7640d04d21a17a43a8d16eda83a4

Contents?: true

Size: 472 Bytes

Versions: 28

Compression:

Stored size: 472 Bytes

Contents

require 'cgi'

module ActiveMerchant
  class PostData < Hash
    class_attribute :required_fields, instance_writer: false
    self.required_fields = []

    def []=(key, value)
      return if value.blank? && !required?(key)

      super
    end

    def to_post_data
      collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
    end

    alias to_s to_post_data

    private

    def required?(key)
      required_fields.include?(key)
    end
  end
end

Version data entries

28 entries across 28 versions & 4 rubygems

Version Path
swiss-crm-activemerchant-1.0.13 lib/active_merchant/post_data.rb
swiss-crm-activemerchant-1.0.12 lib/active_merchant/post_data.rb
swiss-activemerchant-1.0.11 lib/active_merchant/post_data.rb
swiss-activemerchant-1.0.10 lib/active_merchant/post_data.rb
swiss-activemerchant-1.0.9 lib/active_merchant/post_data.rb
swiss-activemerchant-1.0.8 lib/active_merchant/post_data.rb
swiss-activemerchant-1.0.7 lib/active_merchant/post_data.rb
swiss-activemerchant-1.0.6 lib/active_merchant/post_data.rb
swiss-activemerchant-1.0.5 lib/active_merchant/post_data.rb
swiss-activemerchant-1.0.4 lib/active_merchant/post_data.rb
activemerchant-1.137.0 lib/active_merchant/post_data.rb
swiss-activemerchant-1.0.2 lib/active_merchant/post_data.rb
swiss-activemerchant-1.0.1 lib/active_merchant/post_data.rb
activemerchant-1.133.0 lib/active_merchant/post_data.rb
activemerchant-1.131.0 lib/active_merchant/post_data.rb
activemerchant-1.130.0 lib/active_merchant/post_data.rb
activemerchant-1.129.0 lib/active_merchant/post_data.rb
activemerchant-1.126.0 lib/active_merchant/post_data.rb
activemerchant-1.125.0 lib/active_merchant/post_data.rb
archetype2142_activemerchant-1.124.0 lib/active_merchant/post_data.rb