Class: ShellElf::Batch
- Inherits:
-
Object
- Object
- ShellElf::Batch
- Defined in:
- lib/shell_elf/batch.rb
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(params) ⇒ Batch
constructor
A new instance of Batch.
Constructor Details
#initialize(params) ⇒ Batch
Returns a new instance of Batch.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/shell_elf/batch.rb', line 9 def initialize(params) = params[:options] || {} @commands = if params[:command] [params[:command]] elsif params[:commands] params[:commands] else [] end @success_postback = .delete(:success) @failure_postback = .delete(:failure) end |
Class Method Details
.execute(params) ⇒ Object
4 5 6 |
# File 'lib/shell_elf/batch.rb', line 4 def execute(params) new(params).execute end |
Instance Method Details
#execute ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/shell_elf/batch.rb', line 23 def execute return self if @commands.empty? if @commands.all? { |command| Job.execute(command).success? } if @success_postback ShellElf.logger.debug("Posting back to #{@success_postback}") Net::HTTP.post_form(URI.parse(@success_postback), {}) else ShellElf.logger.debug("No success postback given") end elsif @failure_postback ShellElf.logger.debug("Posting back to #{@failure_postback}") Net::HTTP.post_form(URI.parse(@failure_postback), {}) else ShellElf.logger.debug("No failure postback given") end self end |