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 authored and tampakis committed Mar 29, 2018
1 parent 68affcf commit fe2621f
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 127 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Metrics/BlockLength:
- "lib/railties/blacklight.rake"
- "tasks/blacklight.rake"

Metrics/ClassLength:
Exclude:
- "lib/blacklight/configuration.rb"

Metrics/LineLength:
Max: 200

Expand Down
12 changes: 12 additions & 0 deletions lib/blacklight/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,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 fe2621f

Please sign in to comment.