Module: MiniEtl::Status

Included in:
Generator, Process, Source
Defined in:
lib/mini_etl/util/status.rb

Overview

Track a status

Constant Summary collapse

DEFAULT_STATES =
{
  initialized: 0,
  finished: 1,
  failed: 2
}.freeze

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mini_etl/util/status.rb', line 12

def self.included(base)
  attr_reader :status

  states = base.const_defined?(:VALID_STATES) ? base.const_get(:VALID_STATES) : DEFAULT_STATES
  states.each do |verb, value|
    define_method "#{verb}?".to_sym do
      @status == value
    end

    define_method "#{verb}!".to_sym do
      @status = value
    end
  end
end