How to avoid instantiating same object over and over


(Kyunam Kim) #1

I created a filter - some kind of converter.
In the register method, I create an instance variable (i.e, @hexGrid = HexGrid.new(cellSize)) and use it in the filter method.

In a configuration file, I chain my own filter multiple times like this.

filter {
hexgrid {
hex_field => 'orig_hex25'
cellSize => 25
...
}

hexgrid {
hex_field => 'orig_hex50'
cellSize => 50
...
}

hexgrid {
hex_field => 'orig_hex100'
cellSize => 100
...
}
}

I noticed that each time an event comes in and each time this event goes thru a configured filter, an instance variable in the register method gets created every time.

For example, if I have 3 filter configured for my own filter, 1 event comes in, then i see 3 different hexGrid instance variables created.

So, my ultimate question is, is there a way to instantiate an object once, then re-use it for subsequent events coming in?

Thanks!


(Kyunam Kim) #2

Disregard this - I brain-farted.

register method only instantiates variables once PER a configured filter.

Thanks!


(system) #3