Module: Tripleloop::Util
- Defined in:
- lib/tripleloop/util.rb
Defined Under Namespace
Modules: Hash, NestedFetch, String
Class Method Summary
collapse
Class Method Details
.constant(names, context = Kernel) ⇒ Object
49
50
51
52
53
54
|
# File 'lib/tripleloop/util.rb', line 49
def constant(names, context=Kernel)
return context if names.empty?
const_name = names.shift
constant(names, context.const_get(const_name))
end
|
.module(object) ⇒ Object
45
46
47
|
# File 'lib/tripleloop/util.rb', line 45
def module(object)
constant(object.class.name.split('::')[0..-2])
end
|
.with_nested_fetch(object) ⇒ Object
41
42
43
|
# File 'lib/tripleloop/util.rb', line 41
def with_nested_fetch(object)
object.is_a?(Enumerable) ? object.extend(NestedFetch) : object
end
|