Sha256: f1a2282bbc51416fb0ba7307c1ddc11b83ba09a85d299d2bfa6c343d0b1b282f

Contents?: true

Size: 968 Bytes

Versions: 28

Compression:

Stored size: 968 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
require 'eac_envs/http/request/body_field'

module EacEnvs
  module Http
    class Request
      class BodyFields
        common_constructor :source_body

        # @return [Hash, nil]
        def to_h
          fields.if_present do |v|
            v.each_with_object({}) { |e, a| a[e.hash_key] = e.hash_value }
          end
        end

        # @return [Array<EacEnvs::Http::Request::BodyField>, nil]
        def fields
          source_body.if_present do |v|
            next nil unless v.is_a?(::Enumerable)

            if v.is_a?(::Hash)
              ::EacEnvs::Http::Request::BodyField.list_from_hash(v)
            else
              ::EacEnvs::Http::Request::BodyField.list_from_enumerable(v)
            end
          end
        end

        # @return [Boolean]
        def with_file?
          fields.if_present(false) { |v| v.any?(&:with_file?) }
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
eac_envs-http-0.6.1 lib/eac_envs/http/request/body_fields.rb
eac_envs-http-0.6.0 lib/eac_envs/http/request/body_fields.rb
eac_envs-http-0.5.1 lib/eac_envs/http/request/body_fields.rb
eac_envs-http-0.5.0 lib/eac_envs/http/request/body_fields.rb
eac_tools-0.76.0 sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb
eac_tools-0.75.2 sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb
eac_envs-http-0.4.1 lib/eac_envs/http/request/body_fields.rb
eac_tools-0.75.1 sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb
eac_tools-0.75.0 sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb
eac_tools-0.74.1 sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb
eac_tools-0.74.0 sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb
eac_tools-0.73.0 sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb
eac_tools-0.72.0 sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb
eac_envs-http-0.4.0 lib/eac_envs/http/request/body_fields.rb
eac_tools-0.70.1 sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb
eac_tools-0.70.0 sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb
eac_tools-0.69.1 sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb
eac_tools-0.69.0 sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb
eac_tools-0.68.0 sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb
eac_tools-0.67.1 sub/eac_envs-http/lib/eac_envs/http/request/body_fields.rb