Sha256: 71b8194b08f63079a63010cbf9d8685e86842dcb6b2ab615695c9468d48b3022

Contents?: true

Size: 530 Bytes

Versions: 3

Compression:

Stored size: 530 Bytes

Contents

module ActiveGit
  class DbEvent

    def initialize(file_name)
      @file_name = file_name
    end

    def synchronize(synchronizer)
      raise 'Must implement in subclass'
    end

    protected

    def model
      @model ||= File.dirname(@file_name).split(/\/|\\/).pop.classify.constantize
    end

    def model_id
      File.basename(@file_name, '.json')
    end

    def data
      json = File.open(@file_name, 'r') { |f| f.readlines.join("\n") }
      model.from_json(json)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_git-0.0.3 lib/active_git/events/db_event.rb
active_git-0.0.2 lib/active_git/events/db_event.rb
active_git-0.0.1 lib/active_git/events/db_event.rb