diff options
author | Saku Ytti <saku@ytti.fi> | 2015-02-23 20:22:50 +0200 |
---|---|---|
committer | Saku Ytti <saku@ytti.fi> | 2015-02-23 20:22:50 +0200 |
commit | 9145678a23f86ecc52dc3f89999a864f70c2e2d8 (patch) | |
tree | 0b8633b4179d6537e83310c22bb17a051b30a329 /lib/oxidized/model | |
parent | 628ab4e2f74837dc04f7466a60a8783d23d5167a (diff) |
guard against model returning non-string
Return empty string instead of what ever model returned.
Closes #63
Diffstat (limited to 'lib/oxidized/model')
-rw-r--r-- | lib/oxidized/model/model.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/oxidized/model/model.rb b/lib/oxidized/model/model.rb index d3f54b9..45de4d7 100644 --- a/lib/oxidized/model/model.rb +++ b/lib/oxidized/model/model.rb @@ -133,10 +133,10 @@ module Oxidized outputs << out end procs[:pre].each do |pre_proc| - outputs.unshift Oxidized::String.new(instance_eval(&pre_proc)) + outputs.unshift process_cmd_output(instance_eval(&pre_proc), nil) end procs[:post].each do |post_proc| - outputs << Oxidized::String.new(instance_eval(&post_proc)) + outputs << process_cmd_output(instance_eval(&post_proc), nil) end outputs end @@ -152,9 +152,8 @@ module Oxidized private def process_cmd_output output, name - if output.class != Oxidized::String - output = Oxidized::String.new output - end + output = Oxidized::String.new output if ::String === output + output = Oxidized::String.new '' unless Oxidized::String === output output.set_cmd(name) output end |