Module: GMapper::Autoload
- Included in:
- Google::Maps::Static, Google::Maps::Static::Items
- Defined in:
- lib/autoload.rb
Instance Method Summary collapse
- #autoload(const_name, path = nil) ⇒ Object
-
#underscore(camel_cased_word) ⇒ Object
I take no credit for this, it’s obviously ActiveSupport code, just don’t need the depenancy.
Instance Method Details
#autoload(const_name, path = nil) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/autoload.rb', line 5 def autoload( const_name, path = nil ) full_name = [self.name, const_name.to_s, path].compact.join('::') location = path || underscore( full_name ) super const_name, location end |
#underscore(camel_cased_word) ⇒ Object
I take no credit for this, it’s obviously ActiveSupport code, just don’t need the depenancy
14 15 16 17 18 19 20 21 22 |
# File 'lib/autoload.rb', line 14 def underscore(camel_cased_word) word = camel_cased_word.to_s.dup word.gsub!(/::/, '/') word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2') word.gsub!(/([a-z\d])([A-Z])/,'\1_\2') word.tr!("-", "_") word.downcase! word end |