Sha256: 091b9cc303475494425e9b167943b023e514db6072cad0dd2314e92b23644cd6

Contents?: true

Size: 483 Bytes

Versions: 58

Compression:

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

58 entries across 57 versions & 5 rubygems

Version Path
activemerchant-1.61.0 lib/active_merchant/post_data.rb
activemerchant-1.60.0 lib/active_merchant/post_data.rb
activemerchant-1.59.0 lib/active_merchant/post_data.rb
activemerchant-1.58.0 lib/active_merchant/post_data.rb
activemerchant-1.57.0 lib/active_merchant/post_data.rb
activemerchant-1.56.0 lib/active_merchant/post_data.rb
activemerchant-1.55.0 lib/active_merchant/post_data.rb
activemerchant-1.54.0 lib/active_merchant/post_data.rb
activemerchant-1.53.0 lib/active_merchant/post_data.rb
start_activemerchant-1.50.0 lib/active_merchant/post_data.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/activemerchant-1.48.0/lib/active_merchant/post_data.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/activemerchant-1.48.0/lib/active_merchant/post_data.rb
activemerchant-1.52.0 lib/active_merchant/post_data.rb
activemerchant-1.51.0 lib/active_merchant/post_data.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/active_utils-2.2.3/lib/active_utils/common/post_data.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/activemerchant-1.48.0/lib/active_merchant/post_data.rb
activemerchant-1.50.0 lib/active_merchant/post_data.rb
tanga_active_utils-2.2.3.1 lib/active_utils/common/post_data.rb
activemerchant-1.49.0 lib/active_merchant/post_data.rb
tanga_active_utils-2.2.3 lib/active_utils/common/post_data.rb