Skip to content

Commit

Permalink
Refactor comonent config
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Aug 31, 2017
1 parent afd4741 commit a9a491e
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ module ClassMethods
# @option opts [Symbol] :callback method for further processing of documents, receives Array of documents
def add_show_tools_partial(name, opts = {})
blacklight_config.add_show_tools_partial(name, opts)
create_action_handler(name, opts)
end

# Define a simple action handler for the tool as long as the method
# doesn't already exist or the `:define_method` option is not `false`
def create_action_handler(name, opts)
return if method_defined?(name) || opts[:define_method] == false

# Define a simple action handler for the tool
define_method name do
@response, @documents = action_documents

Expand All @@ -70,21 +74,15 @@ def add_show_tools_partial(name, opts = {})

# Add a tool to be displayed for each document in the search results.
# @!macro partial_if_unless
def add_results_document_tool(name, opts = {})
blacklight_config.add_results_document_tool(name, opts)
end
delegate :add_results_document_tool, to: :blacklight_config

# Add a tool to be displayed for the list of search results themselves.
# @!macro partial_if_unless
def add_results_collection_tool(name, opts = {})
blacklight_config.add_results_collection_tool(name, opts)
end
delegate :add_results_collection_tool, to: :blacklight_config

# Add a partial to the header navbar.
# @!macro partial_if_unless
def add_nav_action(name, opts = {})
blacklight_config.add_nav_action(name, opts)
end
delegate :add_nav_action, to: :blacklight_config
end
end
end

0 comments on commit a9a491e

Please sign in to comment.