Sha256: 3da1eb056e1d371d2bd5632d5c818b48c38954be2b0bf8b7ec9ba789ca88328f

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

# @api public
# @since 0.8.0
module SmartCore::Engine::Frozener
  # @api public
  # @since 0.8.0
  module Mixin
    # @return [self]
    #
    # @api public
    # @since 0.8.0
    def freeze
      SmartCore::Engine::Frozener.freeze(self)
    end

    # @return [Boolean]
    #
    # @api public
    # @since 0.8.0
    def frozen?
      SmartCore::Engine::Frozener.frozen?(self)
    end
  end

  # @return [UnboundMethod]
  #
  # @api private
  # @since 0.8.0
  FROZENER = Object.new.method(:freeze).unbind.tap(&:freeze)

  # @return [UnboundMethod]
  #
  # @api private
  # @since 0.8.0
  FROZEN_CHECK = Object.new.method(:frozen?).unbind.tap(&:freeze)

  class << self
    # @param object [Any]
    # @return [object]
    #
    # @api public
    # @since 0.8.0
    def freeze(object)
      FROZENER.bind_call(object)
    end

    # @param object [Any]
    # @return [Boolean]
    #
    # @api public
    # @since 0.8.0
    def frozen?(object)
      FROZEN_CHECK.bind_call(object)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smart_engine-0.8.0 lib/smart_core/engine/frozener.rb