Sha256: a2f7b56534f8333bf2fc88a762b4aa00cfbeec532fbcb0177cc064d46e647021

Contents?: true

Size: 684 Bytes

Versions: 3

Compression:

Stored size: 684 Bytes

Contents

module MangoPay

  # Assures that no fields which are considered read-only
  # remain in a hash meant to be sent as a request body.
  module ReadOnlyFields

    @read_only_fields = %w[
      CreationDate, PaymentData
    ]

    class << self

      # Checks whether any of the fields marked as read-only
      # are present in the given hash. Removes those which are.
      #
      # @param +hash+ [Hash] hash to check for read-only fields
      # @return [Hash] the given hash minus any read-only fields
      #
      # noinspection RubyResolve
      def remove_from!(hash)
        @read_only_fields.each do |field|
          hash.delete field
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mangopay-v4-4.1.0 lib/mangopay/common/read_only_fields.rb
mangopay-v4-4.0.2 lib/mangopay/common/read_only_fields.rb
mangopay-v4-4.0.1 lib/mangopay/common/read_only_fields.rb