Sha256: b2ccff1a59b5c633c2277a21014b8112e6a55620b4db4a32130775683c8e7bb3

Contents?: true

Size: 1.38 KB

Versions: 6

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Common
    module Plugins
      module HasConstructorWithoutInitialize
        module Concern
          include Support::Concern

          class_methods do
            ##
            # @return [Object]
            # @since 0.2.0
            #
            # @internal
            #   NOTE: `allocate` creates an uninitialized object and allocates memory for it.
            #
            #   NOTE: Pseudocode for default `new` implementation.
            #     def new
            #       instance = allocate
            #
            #       instance.send(:initialize)
            #
            #       instance
            #     end
            #
            #   NOTE: Code for `new_without_initialize`.
            #     def new_without_initialize
            #       allocate
            #     end
            #
            #   NOTE: `create` is used instead of `new` in order to avoid the accidental feeling that `new_without_initialize` is Ruby's built-in method.
            #
            #   NOTE: Check the following links for more info.
            #   - https://ruby-doc.org/core-2.5.0/Class.html#method-i-allocate
            #   - https://frontdeveloper.pl/2018/11/ruby-allocate-method/
            #
            def create_without_initialize
              allocate
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
convenient_service-0.12.0 lib/convenient_service/common/plugins/has_constructor_without_initialize/concern.rb
convenient_service-0.11.0 lib/convenient_service/common/plugins/has_constructor_without_initialize/concern.rb
convenient_service-0.10.1 lib/convenient_service/common/plugins/has_constructor_without_initialize/concern.rb
convenient_service-0.10.0 lib/convenient_service/common/plugins/has_constructor_without_initialize/concern.rb
convenient_service-0.9.0 lib/convenient_service/common/plugins/has_constructor_without_initialize/concern.rb
convenient_service-0.8.0 lib/convenient_service/common/plugins/has_constructor_without_initialize/concern.rb