Class: String

Inherits:
Object show all
Defined in:
lib/omega/common.rb

Instance Method Summary collapse

Instance Method Details

#constantizeObject

Taken from activesupport inflector


76
77
78
79
80
81
82
83
84
85
# File 'lib/omega/common.rb', line 76

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

#demodulizeObject


67
68
69
# File 'lib/omega/common.rb', line 67

def demodulize
  self.split('::').last
end

#modulizeObject


71
72
73
# File 'lib/omega/common.rb', line 71

def modulize
  self.split('::')[0..-2].join('::')
end