Sha256: a7339667e0948f4d8f25b753e15a277509d3579291beaa7dcd959922a43b29f1
Contents?: true
Size: 883 Bytes
Versions: 1
Compression:
Stored size: 883 Bytes
Contents
module ActiveGit class DbEvent def initialize(file_name, working_path=nil) @file_name = file_name @working_path = working_path || ActiveGit.configuration.working_path end def synchronize(synchronizer) raise 'Must implement in subclass' end private def model @model ||= Inflector.model(@file_name, @working_path) end def model_id Inflector.model_id @file_name end def data json = File.open(@file_name, 'r') { |f| f.read } model.from_json(json) end def create(synchronizer) synchronizer.bulk_insert data end def delete(synchronizer) synchronizer.define_job do ActiveGit.configuration.logger.debug "[ActiveGit] Deleting #{model.model_name} #{model_id}" record = model.find_by_id(model_id) record.delete if record end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_git-0.0.7 | lib/active_git/events/db_event.rb |