Skip to content

Commit

Permalink
Extract #key_parts private method
Browse files Browse the repository at this point in the history
  • Loading branch information
cllns committed Jan 4, 2025
1 parent a93cfaf commit 58e5850
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/hanami/cli/generators/app/ruby_class_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def write
# @api private
def fully_qualified_name
inflector.camelize(
[namespace, extra_namespace, *key.split(KEY_SEPARATOR)].join("/"),
[namespace, extra_namespace, *key_parts].join("/"),
)
end

Expand Down Expand Up @@ -76,13 +76,13 @@ def file_contents
# @since 2.2.0
# @api private
def class_name
key.split(KEY_SEPARATOR)[-1]
key_parts.last
end

# @since 2.2.0
# @api private
def local_namespaces
Array(extra_namespace) + key.split(KEY_SEPARATOR)[..-2]
Array(extra_namespace) + key_parts[..-2]
end

# @since 2.2.0
Expand Down Expand Up @@ -127,6 +127,12 @@ def class_definition(class_name:, local_namespaces:)
def normalize(name)
inflector.camelize(name).gsub(/[^\p{Alnum}]/, "")
end

# @since 2.2.2
# @api private
def key_parts
key.split(KEY_SEPARATOR)
end
end
end
end
Expand Down

0 comments on commit 58e5850

Please sign in to comment.