Class: SimpleCommandDispatcher::Services::CommandNamespaceService
- Inherits:
-
Object
- Object
- SimpleCommandDispatcher::Services::CommandNamespaceService
- Includes:
- Helpers::Camelize, Helpers::TrimAll
- Defined in:
- lib/simple_command_dispatcher/services/command_namespace_service.rb
Overview
Returns a string of modules that can be subsequently prepended to a class, to create a fully qualified, constantized class.
The command_namespace is provided during initialization and can be a Hash, Array, or String.
Instance Method Summary collapse
-
#initialize(command_namespace:) ⇒ CommandNamespaceService
constructor
A new instance of CommandNamespaceService.
-
#to_class_modules_string ⇒ Object
Handles command module transformations from String, Hash or Array into a fully qualified class modules string (e.g. “A::B::C::”).
Methods included from Helpers::TrimAll
Methods included from Helpers::Camelize
Constructor Details
#initialize(command_namespace:) ⇒ CommandNamespaceService
Returns a new instance of CommandNamespaceService.
30 31 32 |
# File 'lib/simple_command_dispatcher/services/command_namespace_service.rb', line 30 def initialize(command_namespace:) @command_namespace = command_namespace end |
Instance Method Details
#to_class_modules_string ⇒ Object
Handles command module transformations from String, Hash or Array into a fully qualified class modules string (e.g. “A::B::C::”).
36 37 38 39 40 41 42 |
# File 'lib/simple_command_dispatcher/services/command_namespace_service.rb', line 36 def to_class_modules_string return '' if command_namespace.blank? class_modules_string = join_class_modules_if(command_namespace:) class_modules_string = trim_all(camelize(class_modules_string)) "#{class_modules_string}::" end |