Module: Excom::Plugins::Executable

Defined in:
lib/excom/plugins/executable.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#execute(&block) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/excom/plugins/executable.rb', line 17

def execute(*, &block)
  clear_execution_state!
  result = run(&block)
  result_with(result) unless defined? @result
  @executed = true

  self
end

#executed?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/excom/plugins/executable.rb', line 26

def executed?
  @executed
end

#failure?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/excom/plugins/executable.rb', line 70

def failure?
  !success?
end

#initializeObject



8
9
10
11
# File 'lib/excom/plugins/executable.rb', line 8

def initialize(*)
  @executed = false
  super
end

#initialize_cloneObject



13
14
15
# File 'lib/excom/plugins/executable.rb', line 13

def initialize_clone(*)
  clear_execution_state!
end

#result(obj = UNDEFINED) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/excom/plugins/executable.rb', line 40

def result(obj = UNDEFINED)
  return @result if obj == UNDEFINED

  case obj
  when Hash
    if obj.length != 1
      fail ArgumentError, "expected 1-item status-result pair, got: #{obj.inspect}"
    end

    @status, @result = obj.first
  else
    result_with(obj)
  end
end

#status(status = UNDEFINED) ⇒ Object



60
61
62
63
64
# File 'lib/excom/plugins/executable.rb', line 60

def status(status = UNDEFINED)
  return @status = status unless status == UNDEFINED

  @status
end

#success?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/excom/plugins/executable.rb', line 66

def success?
  status == :success || self.class.success_aliases.include?(status)
end