Overlay (overlay)

Overlays are a way to transparently wrap services. They work by taking the name of a service or a group along with the name of an element to be used as the overlay, plus some optional arguments.

When the named service is built the overlay element will be called (with .call) with the built service object and the optional arguments, and it’s result will be what’s returned.

Factories work well as overlay elements.

require 'alki'

assembly = Alki.create_assembly do
  overlay :greeting, :exclaim, 3

  service :greeting do
    'Hello World'

  factory :exclaim do
    -> (string,count) do
      string + ('!' * count)

puts assembly.new.greeting

#output: Hello World!!!

results matching ""

    No results matching ""