class Liebre::Engine::State

Attributes

config[R]
started[R]

Public Class Methods

new(config) click to toggle source
# File lib/liebre/engine/state.rb, line 5
def initialize config
  @config  = config
  @started = Hash.new { |hash, key| hash[key] = {} }
end

Public Instance Methods

to_clean(only: nil) { |type, name, opts| ... } click to toggle source
# File lib/liebre/engine/state.rb, line 19
def to_clean only: nil
  all do |type, name, opts|
    yield(type, name, opts) if match?(type, only)
  end
end
to_start(only: nil) { |type, name, opts| ... } click to toggle source
# File lib/liebre/engine/state.rb, line 10
def to_start only: nil
  all do |type, name, opts|
    if has_to_start?(type, name, only)
      yield(type, name, opts)
      set_started(type, name)
    end
  end
end

Private Instance Methods

all() { |type, name, opts| ... } click to toggle source
# File lib/liebre/engine/state.rb, line 39
def all
  config.each do |type, specs|
    specs.each { |name, opts| yield(type, name, opts) }
  end
end
has_to_start?(type, name, only) click to toggle source
# File lib/liebre/engine/state.rb, line 27
def has_to_start? type, name, only
  started[type][name].nil? and match?(type, only)
end
match?(type, only) click to toggle source
# File lib/liebre/engine/state.rb, line 31
def match? type, only
  only.nil? or only.include?(type)
end
set_started(type, name) click to toggle source
# File lib/liebre/engine/state.rb, line 35
def set_started type, name
  started[type][name] = true
end