Socket
Book a DemoInstallSign in
Socket

acts_as_git

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acts_as_git

0.2.5
bundlerRubygems
Version published
Maintainers
2
Created
Source

Examples

ActiveRecord is not required, but let me write an example for it.

ActsAsGit.configure do |config|
  config.email = 'test@test.com'
  config.username = 'testuser'
end

class Post < ActiveRecord::Base
  include ActsAsGit
  def self.repodir
    "posts"
  end

  def filename
    "#{self.id}_body.txt"
  end
  acts_as_git :body => self.instance_method(:filename)
end

# store
post = Post.new # create the directory `self.repodir` if not exist, and init repo.
post.body = 'content'
post.save # save the content into the file of `#filename`
post.current
  => COMMIT_HASH_HOGE

# load
post = Post.first
puts post.body
  => 'content'

# history
post.body = 'content2'
post.is_changed?
  => true
post.save
post.is_changed?
  => false
post.current
  => COMMIT_HASH_FUGA
puts post.body
  => 'content2'
post.checkout(COMMIT_HASH_HOGE)
puts post.body
  => 'content'

FAQs

Package last updated on 11 Jul 2014

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.