Class: ConvenientService::Utils::Module::GetNamespace Private
- Inherits:
-
Support::Command
- Object
- Support::Command
- ConvenientService::Utils::Module::GetNamespace
- Defined in:
- lib/convenient_service/utils/module/get_namespace.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Returns parent namespace of class or module.
Instance Attribute Summary collapse
- #mod ⇒ Object readonly private
Instance Method Summary collapse
- #call ⇒ Module, ... private
- #initialize(mod) ⇒ void constructor private
Methods inherited from Support::Command
Constructor Details
#initialize(mod) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 |
# File 'lib/convenient_service/utils/module/get_namespace.rb', line 48 def initialize(mod) @mod = mod end |
Instance Attribute Details
#mod ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 |
# File 'lib/convenient_service/utils/module/get_namespace.rb', line 42 def mod @mod end |
Instance Method Details
#call ⇒ Module, ...
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/convenient_service/utils/module/get_namespace.rb', line 56 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 |