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
smulube-activemerchant-1.7.1 lib/active_merchant/common/requires_parameters.rb
smulube-activemerchant-1.7.0.3 lib/active_merchant/common/requires_parameters.rb
activemerchant-1.7.1 lib/active_merchant/common/requires_parameters.rb
johnreitano-activemerchant-1.5.8 lib/active_merchant/lib/requires_parameters.rb
smulube-activemerchant-1.7.0.2 lib/active_merchant/common/requires_parameters.rb
smulube-activemerchant-1.7.0.1 lib/active_merchant/common/requires_parameters.rb
johnreitano-activemerchant-1.5.7 lib/active_merchant/lib/requires_parameters.rb
smulube-activemerchant-1.7.0 lib/active_merchant/common/requires_parameters.rb
active_fulfillment-1.0.0 lib/active_merchant/common/requires_parameters.rb
activemerchant-1.7.0 lib/active_merchant/common/requires_parameters.rb
active_fulfillment-0.10.0 lib/active_merchant/common/requires_parameters.rb
activemerchant-1.6.0 lib/active_merchant/common/requires_parameters.rb
active_shipping-0.9.1 lib/active_merchant/common/requires_parameters.rb
bitfluent-activemerchant-1.5.1.1 lib/active_merchant/common/requires_parameters.rb
johnreitano-activemerchant-1.5.5 lib/active_merchant/lib/requires_parameters.rb
johnreitano-activemerchant-1.5.4 lib/active_merchant/lib/requires_parameters.rb
smulube-activemerchant-1.5.1.4 lib/active_merchant/lib/requires_parameters.rb
smulube-activemerchant-1.5.1.3 lib/active_merchant/lib/requires_parameters.rb
johnreitano-activemerchant-1.5.3 lib/active_merchant/lib/requires_parameters.rb
johnreitano-activemerchant-1.5.2 lib/active_merchant/lib/requires_parameters.rb