Sha256: f1dd8092f57a963a3e3732825254daeb98abda3f590382400db0030ff71b6c7c

Contents?: true

Size: 847 Bytes

Versions: 23

Compression:

Stored size: 847 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Utils
    module Array
      class Wrap < Support::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

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
convenient_service-0.19.1 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.19.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.18.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.17.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.16.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.15.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.14.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.13.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.12.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.11.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.10.1 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.10.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.9.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.8.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.7.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.6.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.5.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.4.0 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.3.1 lib/convenient_service/utils/array/wrap.rb
convenient_service-0.3.0 lib/convenient_service/utils/array/wrap.rb