Sha256: 6b92eb26d5f8733247afd96f286c6f6bad26f3270cced92d5c3d7107145a9216

Contents?: true

Size: 492 Bytes

Versions: 8

Compression:

Stored size: 492 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

8 entries across 8 versions & 5 rubygems

Version Path
activemerchant-1.17.0 lib/active_merchant/common/post_data.rb
yetanothernguyen-activemerchant-1.16.0 lib/active_merchant/common/post_data.rb
activemerchant-1.16.0 lib/active_merchant/common/post_data.rb
gonow-activemerchant-1.15.0 lib/active_merchant/common/post_data.rb
bitfluent-activemerchant-1.15.1 lib/active_merchant/common/post_data.rb
activemerchant-kiddy-1.15.0.kiddy.1 lib/active_merchant/common/post_data.rb
activemerchant-kiddy-1.15.0.kiddy lib/active_merchant/common/post_data.rb
activemerchant-1.15.0 lib/active_merchant/common/post_data.rb