Sha256: 25bf186b76a85ce5e4e987da07b1768bfc16c1b0d30061a5a3a631d12f32e205

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Examples
    module Standard
      module V1
        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
end

Version data entries

4 entries across 4 versions & 1 rubygems

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