Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/coulda/vendor/constantize.rb,
lib/coulda/vendor/underscore.rb
Overview
Slightly tweeked version of #constantize from ActiveSupport 2.3.3
Instance Method Summary collapse
Instance Method Details
#constantize ⇒ Object
:nodoc:
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/coulda/vendor/constantize.rb', line 23 def constantize names = self.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) end constant end |
#super_custom_underscore ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/coulda/vendor/underscore.rb', line 2 def super_custom_underscore self.gsub(/::/, '/'). gsub(/[^A-Za-z0-9]/,'_'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). downcase end |