Skip to content

A small helper class for using ActiveRecord and Audited to group audits together.

Notifications You must be signed in to change notification settings

omgreenfield/omg-audit-group

Repository files navigation

AuditGroup

Group ActiveRecord operations together by assigning all of their audits the same request_uuid.

Requirements

Installation

From RubyGems.org

Globally

gem i omg-audit-group

In Gemfile

gem 'omg-audit-group'

Testing locally

# Build gem
rake build

# Install gem
## From this directory
rake install

## From other directory
gem i -l /path/to/this/folder/omg-audit-group-0.1.0.gem

Usage

Load the gem

require 'audit_group'

Using class methods

# Group operations under the same request_uuid
AuditGroup.request { perform_some_operations }

# View the last request_uuid
AuditGroup.request_uuid

# View the audits from the last request
AuditGroup.audits

# Save the AuditGroup instance for later
audit_group = AuditGroup.current

Saving Request object for later use

# Group operations under the same request_uuid
audit_group = AuditGroup.request { perform_some_operations }

# View the last request_uuid
audit_group.request_uuid

# View the audits from the last request
audit_group.audits

Passing in a request_uuid

AuditGroup.request(request_uuid: some_record.audits.last.request_uuid)

Performing a dry run

View how records would change without committing the transaction

audit_group = AuditGroup.request(dry_run: true) { perform_some_operations }
audit_group.audits

Running tests

bundle exec rspec # option 1
rake spec         # option 2
rspec             # option 3

About

A small helper class for using ActiveRecord and Audited to group audits together.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages