Sha256: 8c31d59c405bfaee83bad231985f492773d085b4751161d04c70dc5874512360

Contents?: true

Size: 651 Bytes

Versions: 18

Compression:

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

18 entries across 18 versions & 3 rubygems

Version Path
solidus_backend-1.0.0.pre vendor/bundle/gems/active_utils-2.2.3/lib/active_utils/common/requires_parameters.rb
tanga_active_utils-2.2.3.1 lib/active_utils/common/requires_parameters.rb
tanga_active_utils-2.2.3 lib/active_utils/common/requires_parameters.rb
active_utils-2.2.3 lib/active_utils/common/requires_parameters.rb
active_utils-2.2.2 lib/active_utils/common/requires_parameters.rb
active_utils-2.2.1 lib/active_utils/common/requires_parameters.rb
active_utils-2.2.0 lib/active_utils/common/requires_parameters.rb
active_utils-2.1.1 lib/active_utils/common/requires_parameters.rb
active_utils-2.1.0 lib/active_utils/common/requires_parameters.rb
active_utils-2.0.2 lib/active_utils/common/requires_parameters.rb
active_utils-2.0.1 lib/active_utils/common/requires_parameters.rb
active_utils-2.0.0 lib/active_utils/common/requires_parameters.rb
active_utils-1.0.5 lib/active_utils/common/requires_parameters.rb
active_utils-1.0.4 lib/active_utils/common/requires_parameters.rb
active_utils-1.0.3 lib/active_utils/common/requires_parameters.rb
active_utils-1.0.2 lib/active_utils/common/requires_parameters.rb
active_utils-1.0.1 lib/active_utils/common/requires_parameters.rb
active_utils-1.0.0 lib/active_utils/common/requires_parameters.rb