Skip to content

Commit

Permalink
better code location for valk override
Browse files Browse the repository at this point in the history
  • Loading branch information
orangewolf committed Oct 11, 2024
1 parent 2756f51 commit fbe8fc7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 0 additions & 8 deletions lib/wings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,6 @@ def self.inspect
:noop
end

Valkyrie.config.resource_class_resolver = lambda do |resource_klass_name|
klass_name = resource_klass_name.gsub(/Resource$/, '')
# Second one should throw a name error because we do not know what you want if
# it isn't one of these two options
klass = klass_name.safe_constantize || resource_klass_name.constantize
Wings::ModelRegistry.reverse_lookup(klass) || klass
end

# some aliases for use by diners of varying sophistication
BuffaloWings = Wings
MightyWings = Wings
Expand Down
9 changes: 9 additions & 0 deletions lib/wings/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ def build_or_set(attributes, &block)
Valkyrie.config.metadata_adapter.query_service.custom_queries.register_query_handler(query_handler)
end

Valkyrie.config.resource_class_resolver = lambda do |resource_klass_name|
return resource_klass_name.constantize unless defined?(Wings)
klass_name = resource_klass_name.gsub(/Resource$/, '')
# Second one should throw a name error because we do not know what you want if
# it isn't one of these two options
klass = klass_name.safe_constantize || resource_klass_name.constantize
Wings::ModelRegistry.reverse_lookup(klass) || klass
end

Wings::ModelRegistry.register(Hyrax::AccessControl, Hydra::AccessControl)
Wings::ModelRegistry.register(Hyrax.config.admin_set_class_for_wings, AdminSet)
Wings::ModelRegistry.register(Hyrax.config.collection_class_for_wings, ::Collection)
Expand Down

0 comments on commit fbe8fc7

Please sign in to comment.