Module: SingleActionService::ModuleHelper

Included in:
Base
Defined in:
lib/single_action_service/module_helper.rb

Instance Method Summary collapse

Instance Method Details

#constantize(string) ⇒ Object



6
7
8
9
10
# File 'lib/single_action_service/module_helper.rb', line 6

def constantize(string)
  string.split('::').inject(Object) do |module_object, class_name|
    module_object.const_get(class_name)
  end
end

#module_parentObject



2
3
4
# File 'lib/single_action_service/module_helper.rb', line 2

def module_parent
  module_parent_name ? constantize(module_parent_name) : Object
end

#module_parent_nameObject



12
13
14
15
16
17
18
19
20
# File 'lib/single_action_service/module_helper.rb', line 12

def module_parent_name
  if defined?(@parent_name)
    @parent_name
  else
    parent_name = name =~ /::[^:]+\z/ ? -$` : nil
    @parent_name = parent_name unless frozen?
    parent_name
  end
end