module ActiveGit::Inflector

Public Class Methods

dirname(model, working_path=nil) click to toggle source
# File lib/active_git/inflector.rb, line 8
def self.dirname(model, working_path=nil)
  "#{working_path || ActiveGit.configuration.working_path}/#{relative_dirname(model)}"
end
filename(instance, working_path=nil) click to toggle source
# File lib/active_git/inflector.rb, line 12
def self.filename(instance, working_path=nil)
  "#{dirname(instance.class, working_path || ActiveGit.configuration.working_path)}/#{instance.id}.json"
end
model(filename, working_path=nil) click to toggle source
# File lib/active_git/inflector.rb, line 20
def self.model(filename, working_path=nil)
  File.dirname(filename.gsub(working_path || ActiveGit.configuration.working_path, '')).classify.constantize
end
model_id(filename) click to toggle source
# File lib/active_git/inflector.rb, line 24
def self.model_id(filename)
  File.basename(filename, '.json')
end
relative_dirname(model) click to toggle source
# File lib/active_git/inflector.rb, line 4
def self.relative_dirname(model)
  model.model_name.underscore.pluralize
end
relative_filename(instance) click to toggle source
# File lib/active_git/inflector.rb, line 16
def self.relative_filename(instance)
  "#{relative_dirname(instance.class)}/#{instance.id}.json"
end