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
johnreitano-activemerchant-1.5.11 lib/active_merchant/lib/requires_parameters.rb
tomriley-active_merchant-1.4.2.11 lib/active_merchant/lib/requires_parameters.rb
tomriley-active_merchant-1.4.2.10 lib/active_merchant/lib/requires_parameters.rb
activemerchant-1.9.0 lib/active_merchant/common/requires_parameters.rb
activemerchant-1.8.0 lib/active_merchant/common/requires_parameters.rb
smulube-activemerchant-1.7.1.5 lib/active_merchant/common/requires_parameters.rb
smulube-activemerchant-1.7.1.4 lib/active_merchant/common/requires_parameters.rb
active_shipping-0.9.3 lib/active_merchant/common/requires_parameters.rb
johnreitano-activemerchant-1.5.10 lib/active_merchant/lib/requires_parameters.rb
activemerchant-1.7.3 lib/active_merchant/common/requires_parameters.rb
johnreitano-activemerchant-1.5.9 lib/active_merchant/lib/requires_parameters.rb
smulube-activemerchant-1.7.1.3 lib/active_merchant/common/requires_parameters.rb
glebm-activemerchant-1.7.2.1 lib/active_merchant/common/requires_parameters.rb
activemerchant-1.7.2 lib/active_merchant/common/requires_parameters.rb
projectdx_activemerchant-1.7.1.20100817.3 lib/active_merchant/common/requires_parameters.rb
projectdx_activemerchant-1.7.1.20100817.2 lib/active_merchant/common/requires_parameters.rb
projectdx_activemerchant-1.7.1.20100817.1 lib/active_merchant/common/requires_parameters.rb
humanzz-activemerchant-1.7.1.1 lib/active_merchant/common/requires_parameters.rb
humanzz-activemerchant-1.7.1 lib/active_merchant/common/requires_parameters.rb
active_shipping-0.9.2 lib/active_merchant/common/requires_parameters.rb