Module: Ledger::HasEvents
- Defined in:
- lib/ledger/has_events.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.rdb ⇒ Object
8 9 10 |
# File 'lib/ledger/has_events.rb', line 8 def self.rdb Nest.new(name, Ledger.redis) end |
Instance Method Details
#add_event(event) ⇒ Object
18 19 20 21 |
# File 'lib/ledger/has_events.rb', line 18 def add_event event event.created_at = Time.now events.lpush event.to_json end |
#event_stream(length = 10) ⇒ Object
12 13 14 15 16 |
# File 'lib/ledger/has_events.rb', line 12 def event_stream length = 10 events.lrange(0, length).map do |json| Ledger::Event.from_json json end end |
#events ⇒ Object
23 24 25 |
# File 'lib/ledger/has_events.rb', line 23 def events rdb[:events] end |
#rdb ⇒ Object
4 5 6 |
# File 'lib/ledger/has_events.rb', line 4 def rdb Nest.new(self.class.name.downcase, Ledger.redis)[to_param] end |