Sha256: 01fb6d9364d25bd6433502eb6a97fd392af5c3a17bc4a7d7bba44e6f48eabd01

Contents?: true

Size: 484 Bytes

Versions: 21

Compression:

Stored size: 484 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_method :to_s, :to_post_data

    private

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

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
activemerchant-1.103.0 lib/active_merchant/post_data.rb
activemerchant-1.102.0 lib/active_merchant/post_data.rb
activemerchant-1.101.0 lib/active_merchant/post_data.rb
activemerchant-1.100.0 lib/active_merchant/post_data.rb
activemerchant-1.99.0 lib/active_merchant/post_data.rb
activemerchant-1.98.0 lib/active_merchant/post_data.rb
active_accountability_merchant-1.97.1 lib/active_merchant/post_data.rb
activemerchant-1.97.0 lib/active_merchant/post_data.rb
activemerchant-1.96.0 lib/active_merchant/post_data.rb
activemerchant-1.95.0 lib/active_merchant/post_data.rb
activemerchant-1.94.0 lib/active_merchant/post_data.rb
activemerchant-1.93.0 lib/active_merchant/post_data.rb
activemerchant-1.92.0 lib/active_merchant/post_data.rb
activemerchant-1.91.0 lib/active_merchant/post_data.rb
activemerchant-1.90.0 lib/active_merchant/post_data.rb
activemerchant-1.89.0 lib/active_merchant/post_data.rb
activemerchant-1.88.0 lib/active_merchant/post_data.rb
activemerchant-1.87.0 lib/active_merchant/post_data.rb
activemerchant-1.86.0 lib/active_merchant/post_data.rb
activemerchant-1.85.0 lib/active_merchant/post_data.rb