Skip to content

Commit

Permalink
Provide separate index configuration per object type
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jan 11, 2017
1 parent 7d6ae32 commit 62c4f6b
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 123 deletions.
12 changes: 12 additions & 0 deletions lib/blacklight/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,18 @@ def add_nav_action(name, opts = {})
add_action(navbar.partials, name, opts)
end

##
# Add a section of config that only applies to documents with a matching display type
def for_display_type display_type, &block
self.fields_for_type ||= {}
fields_for_type[display_type] ||= self.class.new(&block)
end

def index_fields_for(document)
display_type = document.first(index.display_type_field)
for_display_type(display_type).index_fields.merge(index_fields)
end

private

def add_action(config_hash, name, opts)
Expand Down

0 comments on commit 62c4f6b

Please sign in to comment.