lib/riak/map_reduce/phase.rb in riak-client-1.1.1 vs lib/riak/map_reduce/phase.rb in riak-client-1.2.0
- old
+ new
@@ -51,11 +51,11 @@
@language = "erlang"
when Hash
raise ArgumentError, t("stored_function_invalid") unless type == :link || value.has_key?(:bucket) && value.has_key?(:key)
@language = "javascript"
when String
- @language = "javascript"
+ @language = (value =~ /\s*fun\s*\(.*\)\s*->/) ? "erlang" : "javascript"
when WalkSpec
raise ArgumentError, t("walk_spec_invalid_unless_link") unless type == :link
else
raise ArgumentError, t("invalid_function_value", :value => value.inspect)
end
@@ -76,10 +76,10 @@
defaults = {"language" => language, "keep" => keep}
case function
when Hash
defaults.merge(function)
when String
- if function =~ /\s*function/
+ if function =~ /\s*function\s*\(/ || function =~ /\s*fun\s*\(.*\)\s*->/
defaults.merge("source" => function)
else
defaults.merge("name" => function)
end
when Array