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
active_shipping-0.9.9 lib/active_merchant/common/requires_parameters.rb
activemerchant-abn-ideal-1.7.0c lib/active_merchant/common/requires_parameters.rb
activemerchant-abn-ideal-1.7.0b lib/active_merchant/common/requires_parameters.rb
active_shipping-0.9.8 lib/active_merchant/common/requires_parameters.rb
activemerchant-1.11.0 lib/active_merchant/common/requires_parameters.rb
goldstar-activemerchant-1.4.2.6 lib/active_merchant/lib/requires_parameters.rb
active_fulfillment-1.0.3 lib/active_merchant/common/requires_parameters.rb
activemerchant-1.10.0 lib/active_merchant/common/requires_parameters.rb
active_shipping-0.9.7 lib/active_merchant/common/requires_parameters.rb
active_fulfillment-1.0.2 lib/active_merchant/common/requires_parameters.rb
active_shipping-0.9.6 lib/active_merchant/common/requires_parameters.rb
active_shipping-0.9.5 lib/active_merchant/common/requires_parameters.rb
activemerchant-1.9.4 lib/active_merchant/common/requires_parameters.rb
active_fulfillment-1.0.1 lib/active_merchant/common/requires_parameters.rb
active_shipping-0.9.4 lib/active_merchant/common/requires_parameters.rb
activemerchant-1.9.3 lib/active_merchant/common/requires_parameters.rb
activemerchant-1.9.2 lib/active_merchant/common/requires_parameters.rb
n8_activemerchant-1.9.3 lib/active_merchant/common/requires_parameters.rb
maedana-activemerchant-1.9.1.1 lib/active_merchant/common/requires_parameters.rb
activemerchant-1.9.1 lib/active_merchant/common/requires_parameters.rb