class Cell::Util::Inflector
Public Class Methods
constant_for(name)
click to toggle source
WARNING: this API might change.
# File lib/cell/util.rb, line 17 def self.constant_for(name) class_name = name.split("/").collect do |part| part.split('_').collect(&:capitalize).join end.join('::') Object.const_get(class_name, false) end
underscore(constant)
click to toggle source
copied from ActiveSupport.
# File lib/cell/util.rb, line 8 def self.underscore(constant) constant.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end