Sha256: 819839302b51887d045ecbce82958cd8213537cf1e73b4766ca34f834b23f508

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Examples
    module Standard
      class RequestParams
        module Utils
          module Array
            class Wrap < ConvenientService::Command
              ##
              # @!attribute [r] pad
              #   @return [Object] Can be any type.
              #
              attr_reader :object

              ##
              # @param object [Object] Can be any type.
              # @return [void]
              #
              def initialize(object)
                @object = object
              end

              ##
              # @return [Array]
              #
              # @internal
              #   Copied without any modifications from:
              #   https://api.rubyonrails.org/classes/Array.html#method-c-wrap
              #
              def call
                if object.nil?
                  []
                elsif object.respond_to?(:to_ary)
                  object.to_ary || [object]
                else
                  [object]
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
convenient_service-0.17.0 lib/convenient_service/examples/standard/request_params/utils/array/wrap.rb
convenient_service-0.16.0 lib/convenient_service/examples/standard/request_params/utils/array/wrap.rb
convenient_service-0.15.0 lib/convenient_service/examples/standard/request_params/utils/array/wrap.rb
convenient_service-0.14.0 lib/convenient_service/examples/standard/request_params/utils/array/wrap.rb
convenient_service-0.13.0 lib/convenient_service/examples/standard/request_params/utils/array/wrap.rb