Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pack namespace #3

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/annotate/annotate_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,14 @@ def get_model_class(file)
# Retrieve loaded model class
def get_loaded_model(model_path, file)
unless skip_subdirectory_model_load
if defined?(Packs)
# adds pack namespace to model path
pack_name = file[/(packs\/[^\/]+)\//, 1]
pack = Packs.find(pack_name) if pack_name
model_namespace = pack_name[/packs\/(.+)/, 1] if pack && pack.raw_hash.dig('metadata', 'automatic_pack_namespace') == true
model_path = "#{model_namespace}/#{model_path}" if model_namespace
end

loaded_model_class = get_loaded_model_by_path(model_path)
return loaded_model_class if loaded_model_class
end
Expand Down
Loading