Class: ConvenientService::Utils::Module::GetNamespace
- Inherits:
-
Support::Command
- Object
- Support::Command
- ConvenientService::Utils::Module::GetNamespace
- Defined in:
- lib/convenient_service/utils/module/get_namespace.rb
Instance Attribute Summary collapse
-
#mod ⇒ Object
readonly
Returns the value of attribute mod.
Instance Method Summary collapse
- #call ⇒ Module, ...
- #initialize(mod) ⇒ void constructor
Methods inherited from Support::Command
Constructor Details
#initialize(mod) ⇒ void
43 44 45 |
# File 'lib/convenient_service/utils/module/get_namespace.rb', line 43 def initialize(mod) @mod = mod end |
Instance Attribute Details
#mod ⇒ Object (readonly)
Returns the value of attribute mod.
37 38 39 |
# File 'lib/convenient_service/utils/module/get_namespace.rb', line 37 def mod @mod end |
Instance Method Details
#call ⇒ Module, ...
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/convenient_service/utils/module/get_namespace.rb', line 51 def call return unless mod.name return unless mod.name.include?("::") namespace_name = mod.name.split("::")[0..-2].join("::") begin ::Object.const_get(namespace_name, false) rescue ::NameError ::ConvenientService.raise Exceptions::NestingUnderAnonymousNamespace.new(mod: mod, namespace: namespace_name) end end |