Skip to content

Commit

Permalink
14545 - Data inputs should be optional
Browse files Browse the repository at this point in the history
In the past functions without any parameters returned a function hash
with and empty string as parameter.

Functions without parameters now return a function hash with nil as
parameter.
  • Loading branch information
ploubser authored and ripienaar committed May 17, 2012
1 parent 8e11bad commit 3573cfe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/mcollective/matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ def self.create_function_hash(function_call)

# Grab function name and parameters from left compare string
func_hash["name"], func_hash["params"] = f.split("(")
func_hash["params"] = func_hash["params"].gsub(")", "").gsub(/'|"/, "")
if func_hash["params"] == ")"
func_hash["params"] = nil
else
func_hash["params"] = func_hash["params"].gsub(")", "").gsub(/'|"/, "")
end

func_hash
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module MCollective
it "should create a correct hash when no parameters are given" do
result = Matcher.create_function_hash("foo()<=1")
result["value"].should == nil
result["params"].should == ""
result["params"].should == nil
result["r_compare"].should == "1"
result["operator"].should == "<="
result["name"].should == "foo"
Expand Down

0 comments on commit 3573cfe

Please sign in to comment.