Sha256: 00aac0cd3495ef4e334278e338f9907ea453f46c7125b1220872dc7ec028c76e

Contents?: true

Size: 623 Bytes

Versions: 1

Compression:

Stored size: 623 Bytes

Contents

module ActiveGit
  module Inflector

    def self.dirname(model, working_path=nil)
      "#{working_path || ActiveGit.configuration.working_path}/#{model.model_name.underscore.pluralize}"
    end

    def self.filename(instance, working_path=nil)
      "#{dirname(instance.class, working_path || ActiveGit.configuration.working_path)}/#{instance.id}.json"
    end

    def self.model(filename, working_path=nil)
      File.dirname(filename.gsub(working_path || ActiveGit.configuration.working_path, '')).classify.constantize
    end

    def self.model_id(filename)
      File.basename(filename, '.json')
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_git-0.0.4 lib/active_git/inflector.rb