Sha256: 54c3ee2ac314b2ad502b20b88af126b09e28e12fcc3cc860bd11effe3bcc0941
Contents?: true
Size: 1.57 KB
Versions: 1
Compression:
Stored size: 1.57 KB
Contents
# frozen_string_literal: true module Lite module Command STATES = [ PENDING = "pending", EXECUTING = "executing", COMPLETE = "complete", DNF = "dnf" ].freeze module Internals module Executable def execute around_execution { call } rescue StandardError => e fn = e.respond_to?(:fault_name) ? e.fault_name : ERROR send(:"#{fn}", e) after_execution send(:"on_#{fn}", e) end def execute! around_execution { call } rescue StandardError => e after_execution raise(e) unless raise_dynamic_faults? && e.is_a?(Lite::Command::Fault) raise_dynamic_fault(e) end def state @state || PENDING end def executed? dnf? || complete? end STATES.each do |s| # eg: executing? define_method(:"#{s}?") { state == s } # eg: dnf! define_method(:"#{s}!") { @state = s } end private def before_execution increment_execution_index assign_execution_cid start_monotonic_time executing! on_before_execution end def after_execution fault? ? dnf! : complete! on_after_execution stop_monotonic_time append_execution_result freeze_execution_objects end def around_execution before_execution yield after_execution end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lite-command-2.0.2 | lib/lite/command/internals/executable.rb |