Expose Agent#id to Liquid (and to JavaScriptAgent)

This commit is contained in:
Akinori MUSHA 2017-01-05 23:56:42 +09:00
parent 2dab52ae9b
commit a5874da0ae
2 changed files with 19 additions and 18 deletions

View file

@ -445,19 +445,20 @@ class AgentDrop
@object.short_type
end
METHODS = [
:name,
:type,
:options,
:memory,
:sources,
:receivers,
:schedule,
:controllers,
:control_targets,
:disabled,
:keep_events_for,
:propagate_immediately,
METHODS = %i[
id
name
type
options
memory
sources
receivers
schedule
controllers
control_targets
disabled
keep_events_for
propagate_immediately
]
METHODS.each { |attr|

View file

@ -1013,11 +1013,11 @@ describe AgentDrop do
expect(@efa.to_liquid.class).to be(AgentDrop)
end
it 'should have .type and .name' do
t = '{{agent.type}}: {{agent.name}}'
expect(interpolate(t, @wsa1)).to eq('WebsiteAgent: XKCD')
expect(interpolate(t, @wsa2)).to eq('WebsiteAgent: Dilbert')
expect(interpolate(t, @efa)).to eq('EventFormattingAgent: Formatter')
it 'should have .id, .type and .name' do
t = '[{{agent.id}}]{{agent.type}}: {{agent.name}}'
expect(interpolate(t, @wsa1)).to eq("[#{@wsa1.id}]WebsiteAgent: XKCD")
expect(interpolate(t, @wsa2)).to eq("[#{@wsa2.id}]WebsiteAgent: Dilbert")
expect(interpolate(t, @efa)).to eq("[#{@efa.id}]EventFormattingAgent: Formatter")
end
it 'should have .options' do