Sha256: 97fc572adb1d2a661d6065e438c3d6ffadba0f82cc71435e5a6597cd20a64dfb

Contents?: true

Size: 405 Bytes

Versions: 3

Compression:

Stored size: 405 Bytes

Contents

# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "signal"

class Contact
  include Signal

  attr_reader :name, :email

  def initialize(name, email)
    @name = name
    @email = email
  end

  def output!
    emit(:output, self)
  end
end

contact = Contact.new("John Doe", "john@example.org")
contact.on(:output) {|c| puts c.name, c.email }
contact.output!

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
signal-1.3.1 examples/block_context.rb
signal-1.3.0 examples/block_context.rb
signal-1.2.0 examples/block_context.rb