summaryrefslogtreecommitdiff
path: root/lib/oxidized/model/model.rb
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2013-04-21 17:44:38 +0300
committerSaku Ytti <saku@ytti.fi>2013-04-21 17:44:38 +0300
commit4a01f154c1873b898476ff8765ced02c9a916746 (patch)
tree57a991e1166cf3ed939b68583ac51341848f5d0b /lib/oxidized/model/model.rb
parente5ed57cbc77b241e93942af22b1d90efcfe1267f (diff)
run Model::cmd(:all) for Model#cmd as well
Diffstat (limited to 'lib/oxidized/model/model.rb')
-rw-r--r--lib/oxidized/model/model.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/oxidized/model/model.rb b/lib/oxidized/model/model.rb
index b768bfb..a0717cf 100644
--- a/lib/oxidized/model/model.rb
+++ b/lib/oxidized/model/model.rb
@@ -40,6 +40,7 @@ module Oxidized
def cmd string
out = @input.cmd string
+ out = cmd_all out
out = yield out if block_given?
out
end
@@ -56,9 +57,7 @@ module Oxidized
data = ''
self.class.cmds[:cmd].each do |cmd, cmd_block|
out = @input.cmd cmd
- self.class.cmds[:all].each do |all_block|
- out = instance_exec out, &all_block
- end
+ out = cmd_all out
out = instance_exec out, &cmd_block if cmd_block
data << out.to_s
end
@@ -74,5 +73,13 @@ module Oxidized
data
end
+ private
+
+ def cmd_all string
+ self.class.cmds[:all].each do |block|
+ string = instance_exec string, &block
+ end
+ string
+ end
end
end