Class: OpenWFE::Journal::Bucket
- Inherits:
-
Object
- Object
- OpenWFE::Journal::Bucket
- Defined in:
- lib/openwfe/expool/journal.rb
Overview
for each process instance, there is one bucket holding the events waiting to get written in the journal
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #<<(event) ⇒ Object
- #flush ⇒ Object
-
#initialize(path) ⇒ Bucket
constructor
A new instance of Bucket.
- #size ⇒ Object (also: #length)
Constructor Details
#initialize(path) ⇒ Bucket
Returns a new instance of Bucket.
196 197 198 199 200 |
# File 'lib/openwfe/expool/journal.rb', line 196 def initialize (path) super() @path = path @events = [] end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
194 195 196 |
# File 'lib/openwfe/expool/journal.rb', line 194 def events @events end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
194 195 196 |
# File 'lib/openwfe/expool/journal.rb', line 194 def path @path end |
Instance Method Details
#<<(event) ⇒ Object
202 203 204 |
# File 'lib/openwfe/expool/journal.rb', line 202 def << (event) @events << event end |
#flush ⇒ Object
211 212 213 214 215 216 217 218 |
# File 'lib/openwfe/expool/journal.rb', line 211 def flush File.open(@path, "a+") do |f| @events.each do |e| f.puts e end end @events.clear end |
#size ⇒ Object Also known as: length
206 207 208 |
# File 'lib/openwfe/expool/journal.rb', line 206 def size @events.size end |