Class: FrameJournal
- Inherits:
-
Object
- Object
- FrameJournal
- Defined in:
- lib/frame_journal.rb
Instance Method Summary collapse
- #[](msgid) ⇒ Object
- #[]=(msgid, frame) ⇒ Object
- #clear ⇒ Object
- #delete(msgid) ⇒ Object
- #index ⇒ Object
-
#initialize(directory = 'frame-journal', snap_freq = 60 * 5) ⇒ FrameJournal
constructor
A new instance of FrameJournal.
- #keys ⇒ Object
- #next_index ⇒ Object
- #system_id ⇒ Object
Constructor Details
#initialize(directory = 'frame-journal', snap_freq = 60 * 5) ⇒ FrameJournal
Returns a new instance of FrameJournal.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/frame_journal.rb', line 51 def initialize(directory='frame-journal', snap_freq = 60 * 5) @directory = directory @mad = AutomaticSnapshotMadeleine.new(directory) do MadFrameJournal.new end # always snap on startup, in case we had an previous failure @modified = true Thread.new(@mad, snap_freq) do |mad, freq| while true sleep(freq) mad.take_snapshot if @modified @modified = false end end end |
Instance Method Details
#[](msgid) ⇒ Object
73 74 75 |
# File 'lib/frame_journal.rb', line 73 def [](msgid) @mad.system.lookup(msgid) end |
#[]=(msgid, frame) ⇒ Object
68 69 70 71 |
# File 'lib/frame_journal.rb', line 68 def []=(msgid, frame) @modified = true @mad.system.add(msgid, frame) end |
#clear ⇒ Object
86 87 88 89 90 |
# File 'lib/frame_journal.rb', line 86 def clear @modified = true @mad.system.clear @mad.take_snapshot end |
#delete(msgid) ⇒ Object
77 78 79 80 |
# File 'lib/frame_journal.rb', line 77 def delete(msgid) @modified = true @mad.system.delete(msgid) end |
#index ⇒ Object
92 93 94 |
# File 'lib/frame_journal.rb', line 92 def index @mad.system.frame_index end |
#keys ⇒ Object
82 83 84 |
# File 'lib/frame_journal.rb', line 82 def keys @mad.system.frames.keys end |
#next_index ⇒ Object
96 97 98 99 |
# File 'lib/frame_journal.rb', line 96 def next_index @modified = true @mad.system.frame_index += 1 end |
#system_id ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'lib/frame_journal.rb', line 101 def system_id unless name = @mad.system.system_id # todo - grab default name from some place smarter... @modified = true @mad.system.system_id = 'cmastomp' name = @mad.system.system_id end name end |