-
Notifications
You must be signed in to change notification settings - Fork 0
/
publicist.rb
46 lines (39 loc) · 1.04 KB
/
publicist.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class Publicist
attr_reader :broadcaster
def initialize
@clientele = {}
end
def add client
@clientele[client.stage_name] = package client
end
def broadcaster=(broad)
@broadcaster = broad.register_channel
end
def remove client
@clientele.delete client.stage_name
end
def prep client, hash
out = package client
out[:methods].push hash unless hash.empty?
@clientele[client.stage_name] = out
out
end
def package client
meths = client.ongoing_engagements.map do |x|
x.select { |k| [:name, :args, :block, :yield, :result].include? k }
end
{
name: client.stage_name,
obj: client.ward,
methods: meths
}
end
def publicize client, meth_hash
prep client, meth_hash
@broadcaster.broadcast(
label: 'update',
parcel: @clientele.values
) if @broadcaster
end
alias_method :publicise, :publicize
end