Sha256: acbc9de1865340f77e10a9ebcc44a4852d548b422e4fbb484506e86eda99b430

Contents?: true

Size: 657 Bytes

Versions: 129

Compression:

Stored size: 657 Bytes

Contents

module ActiveMerchant #:nodoc:
  module RequiresParameters #:nodoc:
    def requires!(hash, *params)
      params.each do |param| 
        if param.is_a?(Array)
          raise ArgumentError.new("Missing required parameter: #{param.first}") unless hash.has_key?(param.first) 

          valid_options = param[1..-1]
          raise ArgumentError.new("Parameter: #{param.first} must be one of #{valid_options.to_sentence(:words_connector => 'or')}") unless valid_options.include?(hash[param.first])
        else
          raise ArgumentError.new("Missing required parameter: #{param}") unless hash.has_key?(param) 
        end
      end
    end    
  end
end

Version data entries

129 entries across 129 versions & 31 rubygems

Version Path
patmaddox-activemerchant-1.4.2.3 lib/active_merchant/lib/requires_parameters.rb
patmaddox-activemerchant-1.4.2.2 lib/active_merchant/lib/requires_parameters.rb
patmaddox-activemerchant-1.4.2.1 lib/active_merchant/lib/requires_parameters.rb
activemerchant-est-1.4.2.5 lib/active_merchant/lib/requires_parameters.rb
patmaddox-activemerchant-1.4.2 lib/active_merchant/lib/requires_parameters.rb
active_shipping-0.0.2 lib/active_shipping/lib/requires_parameters.rb
abtain_billing-1.0 lib/active_merchant/lib/requires_parameters.rb
active_shipping-0.0.1 lib/active_shipping/lib/requires_parameters.rb
activemerchant-1.4.2 lib/active_merchant/lib/requires_parameters.rb