class ActiveAudit::StorageAdapters::MongoAdapter

Public Class Methods

new(options={}) click to toggle source
# File lib/active_audit/storage_adapters/mongo_adapter.rb, line 7
def initialize options={}
  client = ::Mongo::Client.new options['hosts'], options['options'].symbolize_keys
  @collection = client[:audits]
end

Public Instance Methods

find_by_record(record, options={}) click to toggle source
# File lib/active_audit/storage_adapters/mongo_adapter.rb, line 12
def find_by_record record, options={}
  result = @collection.find(type: record.class.auditing_options[:type], item_id: record.id)
  result.map { |audit| ActiveAudit::Audit.new audit.symbolize_keys }
end
save(audit) click to toggle source
# File lib/active_audit/storage_adapters/mongo_adapter.rb, line 17
def save audit
  @collection.insert_one(audit.attributes)
end