Sha256: d61002f11cca372073c32f023b64de61ceb0d66b09f509f243f2350885dd0110

Contents?: true

Size: 755 Bytes

Versions: 1

Compression:

Stored size: 755 Bytes

Contents

# frozen_string_literal: true

# @api private
# @since 0.1.0
module SmartCore::ValueObject::Interface::Enumerable
  class << self
    # @param base_klass [Class<SmartCore::ValueObject>]
    # @return [void]
    #
    # @api private
    # @since 0.1.0
    def included(base_klass)
      base_klass.include(::Enumerable)
      base_klass.include(Enumerability)
    end
  end

  # @api private
  # @since 0.1.0
  module Enumerability
    # @param block [Block]
    # @return [Enumerable]
    #
    # @api public
    # @since 0.1.0
    # rubocop:disable Style/RedundantParentheses
    def each(&block)
      block_given? ? yield(self) : (Enumerator.new { |yielder| yielder.yield(self) }.each)
    end
    # rubocop:enable Style/RedundantParentheses
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smart_value-object-0.2.0 lib/smart_core/value_object/interface/enumerable.rb