Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

snapcher

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snapcher

  • 0.3.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

snapcher_logo


Snapcher

Gem Version GitHub

Snapcher is an ORM extension that logs changes to specific columns to your model.

When a change is made to a specific column, the difference between before and after the change is obtained and saved.

To make it easier for analysts, save the table name, column name, and data before and after changes as separate columns.

The name of this gem comes from one of Hideo Kojima's game works, "Snatcher".

It was the first of his game works to introduce cinematic direction, and "Snapcher" is also the first of my gem works.

Supported

Snapcher supports Ruby versions:

  • 3.1
  • 3.2

Snapcher supports Rails versions:

  • 7.0
  • 7.1

Supported ORMs

Snapcher is currently ActiveRecord-only.

Installation

Add the gem to your Gemfile:

gem "snapcher"

Then, from your Rails app directory, create the scannings table:

$ rails generate snapcher:install
$ rails db:migrate

Usage

Simply call scanning on your models.

Use column_name: to select the column you want to log.

class User < ActiveRecord::Base
  scanning column_name: "name"
end

By default, whenever a user is created, updated or destroyed, a new scanning is created.

user = User.create!(name: "Gillian Seed")
user.scannings.count # => 1
user.update!(name: "Mika Slayton")
user.scannings.count # => 2
user.destroy
user.scannings.count # => 3

Scanning contain information regarding what action was taken on the model and what changes were made.

user.update!(name: "Mika Slayton")
snapcher = user.scannings.last
snapcher.action # => "update"
snapcher.before_params # => "Gillian Seed"
snapcher.after_params # => "Mika Slayton"

If the "Snatcher" column you want to capture is not user_id, you can specify this.

class User < ActiveRecord::Base
  scanning column_name: "name", snatch_user: "id"
end

FAQs

Package last updated on 25 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc