Sha256: 233f84a8dd5275c7e962f844dfa9b41e792e8255d0847b73e1a65ac4a4e7c332

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

# @api public
# @since 0.8.0
# @version 0.9.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
    # @version 0.9.0
    def freeze(object)
      FROZENER.bind(object).call
    end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
smart_engine-0.12.0 lib/smart_core/engine/frozener.rb
smart_engine-0.11.0 lib/smart_core/engine/frozener.rb
smart_engine-0.10.0 lib/smart_core/engine/frozener.rb
smart_engine-0.9.0 lib/smart_core/engine/frozener.rb