Skip to content

Commit

Permalink
Allow show tool actions to skip defining an accessor method
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Nov 5, 2015
1 parent 9220f5e commit 061cc15
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ module ClassMethods
def add_show_tools_partial name, opts = {}
blacklight_config.add_show_tools_partial(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 @@ -57,7 +60,7 @@ def add_show_tools_partial name, opts = {}
format.js { render :layout => false }
end
end
end unless method_defined? name
end
end

##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def some_existing_action
subject.add_show_tools_partial :some_existing_action
expect(subject.new.some_existing_action).to eq 1
end

it "should allow the configuration to opt out of creating a method" do
subject.add_show_tools_partial :some_missing_action, define_method: false
expect(subject.new).not_to respond_to :some_missing_action
end
end


Expand Down

0 comments on commit 061cc15

Please sign in to comment.