Module: Audit::Log
- Defined in:
- lib/audit/log.rb
Overview
Methods for manipulating audit data stored in Cassandra.
Class Method Summary collapse
-
.audits(bucket, key) ⇒ Object
Fetch all audits for a given record.
-
.clear! ⇒ Object
Clear all audit data.
-
.record(bucket, key, timestamp, changes) ⇒ Object
Store an audit record.
Class Method Details
.audits(bucket, key) ⇒ Object
Fetch all audits for a given record.
bucket - the String name for the logical bucket this audit record belongs
to (i.e. table)
key - the String key into the logical bucket
Returns an Array of Changeset objects
34 35 36 37 38 39 40 |
# File 'lib/audit/log.rb', line 34 def self.audits(bucket, key) # TODO: figure out how to do pagination here payload = connection.get(:Audits, "#{bucket}:#{key}", :reversed => true) payload.values.map do |p| Audit::Changeset.from_enumerable(Yajl::Parser.parse(p)) end end |
.clear! ⇒ Object
Clear all audit data. Note that this doesn’t yet operate on logical buckets. All of the audit data is destroyed. Proceed with caution.
Returns nothing.
47 48 49 50 |
# File 'lib/audit/log.rb', line 47 def self.clear! # It'd be nice if this could clear one bucket at a time connection.clear_keyspace! end |
.record(bucket, key, timestamp, changes) ⇒ Object
Store an audit record.
bucket - the String name for the logical bucket this audit record belongs
to (i.e. table)
key - the String key into the logical bucket timestamp - timestamp to use for this record’s UUID changes - the changes hash (as generated by ActiveRecord) to store
Returns nothing.
21 22 23 24 25 |
# File 'lib/audit/log.rb', line 21 def self.record(bucket, key, , changes) json = Yajl::Encoder.encode(changes) payload = { => json} connection.insert(:Audits, "#{bucket}:#{key}", payload) end |