Class: Hanami::Extensions::Action::NameInferrer Private
- Inherits:
-
Object
- Object
- Hanami::Extensions::Action::NameInferrer
- Defined in:
- lib/hanami/extensions/action/name_inferrer.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.
Infers an action's name (e.g. posts.show) from its class name relative to its slice
namespace.
Class Method Summary collapse
-
.call(action_class_name:, slice:) ⇒ String?
private
The inferred name, or nil if
action_class_nameis nil.
Class Method Details
.call(action_class_name:, slice:) ⇒ String?
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.
Returns the inferred name, or nil if action_class_name is nil.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hanami/extensions/action/name_inferrer.rb', line 20 def call(action_class_name:, slice:) return nil unless action_class_name slice .inflector .underscore(action_class_name) .sub(%r{^#{slice.slice_name.path}#{PATH_DELIMITER}}, "") .sub(%r{^#{slice.config.actions.name_inference_base}#{PATH_DELIMITER}}, "") .gsub("/", CONTAINER_KEY_DELIMITER) end |