Sha256: 7acf818511a8f1e9bfe434b80d356aa8e515a51ae600a24f3ae2dceddfc86b40

Contents?: true

Size: 697 Bytes

Versions: 1

Compression:

Stored size: 697 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
    ]

    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

1 entries across 1 versions & 1 rubygems

Version Path
mangopay-v4-4.0.0 lib/mangopay/common/read_only_fields.rb