0.0
No commit activity in last 3 years
No release in over 3 years
Make your field act as a git repo. Save the content to a file, and load the content from a file.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0

Runtime

>= 0
 Project Readme

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'