Sha256: b60fb658a9cb0d893ec616a01fde73f2b90320fa17215eb0ac28a4aecbf26716

Contents?: true

Size: 562 Bytes

Versions: 3

Compression:

Stored size: 562 Bytes

Contents

module ActiveGit
  class FileEvent

    def initialize(data, path=nil)
      @data = data
      @path = path || ActiveGit.configuration.working_path
    end

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

    protected

    def model
      @data.class.to_s.classify.constantize
    end

    def model_path
      "#{@path}/#{model.table_name}"
    end

    def file_name
      "#{model_path}/#{@data.id}.json"
    end

    def json
      JSON.pretty_generate(@data.attributes)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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