require "objectteam"
require "../../simple/counter"

#create 3 instances of Simple.
e = Simple.new("earth")
m = Simple.new("mars")
v = Simple.new("venus")

#create connector with applied block.
#this block is called, whenever a role object must be instantiated.
#the baseobject plus the roleclass, defined by the connector is given.
countteam = CountHello.new() { |base, roleclass|
  #we will count only those hellos, from planets where name includes an "e"
  result = nil
  if (base.name.include?("e"))
    puts "\n----->create role for #{base.to_s}\n"
    result = roleclass.new
  else
    puts "\n----->no counting role for #{base.to_s}\n"
  end
  result
}

#activate connector
countteam.while_active {
  e.hello
  m.hello
  v.hello
}


