Class: Module
Overview
:nodoc:
Instance Method Summary collapse
- #const_set_full(name, val) ⇒ Object
- #last_name ⇒ Object
- #parent_module(n = 1) ⇒ Object
-
#subclass_of?(klass) ⇒ Boolean
This is here just to be able to call this method on all constants.
Instance Method Details
#const_set_full(name, val) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/spiderfw/utils/monkey/module.rb', line 18 def const_set_full(name, val) mod = self parts = name.to_s.split('::') parts[0..-2].each do |part| unless mod.const_defined?(part.to_sym) mod.const_set(part.to_sym, Module.new) end mod = mod.const_get(part.to_sym) end mod.const_set(parts[-1].to_sym, val) end |
#last_name ⇒ Object
14 15 16 |
# File 'lib/spiderfw/utils/monkey/module.rb', line 14 def last_name self.to_s.split('::')[-1].to_sym end |
#parent_module(n = 1) ⇒ Object
8 9 10 11 12 |
# File 'lib/spiderfw/utils/monkey/module.rb', line 8 def parent_module(n=1) part = self.to_s.reverse.split('::', n+1)[n] return nil if part.blank? return const_get_full(part.reverse) end |
#subclass_of?(klass) ⇒ Boolean
This is here just to be able to call this method on all constants
4 5 6 |
# File 'lib/spiderfw/utils/monkey/module.rb', line 4 def subclass_of?(klass) return false end |