From 4a01f154c1873b898476ff8765ced02c9a916746 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Sun, 21 Apr 2013 17:44:38 +0300 Subject: run Model::cmd(:all) for Model#cmd as well --- lib/oxidized/model/model.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lib/oxidized/model') 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 -- cgit v1.2.1