Module: Farce::Shareable::Delegated

Overview

A structurally frozen wrapper whose logical frozen state is owned by its backend. The including class must implement a private freeze_backend method.

Examples:

Delegate freezing to a counter

class Tally
  include Farce::Shareable::Delegated

  def initialize
    @counter = Farce::Counter.new
    super
  end

  def increment = @counter.increment
  private def freeze_backend = @counter
end

tally = Tally.new
tally.frozen?  # => false
tally.freeze
tally.increment # raises FrozenError in the counter

Method Summary

Methods included from Farce::Shareable

#initialize, #ractor_shareable?