Sha256: 623361ca7c4f9a350e6f137eb43b4fc35ce08df15e35b722d27c721443e7aaf6

Contents?: true

Size: 503 Bytes

Versions: 58

Compression:

Stored size: 503 Bytes

Contents

require 'cgi'

module ActiveMerchant
  class PostData < Hash
    class_inheritable_accessor :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

58 entries across 58 versions & 13 rubygems

Version Path
projectdx_activemerchant-1.7.1.20100817.3 lib/active_merchant/common/post_data.rb
projectdx_activemerchant-1.7.1.20100817.2 lib/active_merchant/common/post_data.rb
projectdx_activemerchant-1.7.1.20100817.1 lib/active_merchant/common/post_data.rb
humanzz-activemerchant-1.7.1.1 lib/active_merchant/common/post_data.rb
humanzz-activemerchant-1.7.1 lib/active_merchant/common/post_data.rb
active_shipping-0.9.2 lib/active_merchant/common/post_data.rb
smulube-activemerchant-1.7.1 lib/active_merchant/common/post_data.rb
smulube-activemerchant-1.7.0.3 lib/active_merchant/common/post_data.rb
activemerchant-1.7.1 lib/active_merchant/common/post_data.rb
smulube-activemerchant-1.7.0.2 lib/active_merchant/common/post_data.rb
smulube-activemerchant-1.7.0.1 lib/active_merchant/common/post_data.rb
smulube-activemerchant-1.7.0 lib/active_merchant/common/post_data.rb
active_fulfillment-1.0.0 lib/active_merchant/common/post_data.rb
activemerchant-1.7.0 lib/active_merchant/common/post_data.rb
active_fulfillment-0.10.0 lib/active_merchant/common/post_data.rb
activemerchant-1.6.0 lib/active_merchant/common/post_data.rb
active_shipping-0.9.1 lib/active_merchant/common/post_data.rb
bitfluent-activemerchant-1.5.1.1 lib/active_merchant/common/post_data.rb