Sha256: a39e52c613a3b3793877cac869e437d3dc7af7c46c433707aad3e48f6006ca90

Contents?: true

Size: 839 Bytes

Versions: 2

Compression:

Stored size: 839 Bytes

Contents

require 'anvil/task/class_methods'
require 'anvil/task/naming'
require 'anvil/task/options'

module Anvil
  class Task
    extend ClassMethods
    extend Naming
    extend Options

    attr_reader :options

    def initialize(options = {})
      @options = options
    end

    def run
      if run_assures
        run_before_callbacks
        run_task
        run_after_callbacks
      end
    end

    def logger
      Anvil.logger
    end

    protected

    def run_after_callbacks
      self.class.afters.each do |after|
        after[0].new(after[1]).run
      end
    end

    def run_assures
      self.class.assures.map { |a| a.new.assured? }.all?
    end

    def run_before_callbacks
      self.class.befores.each do |before|
        before[0].new(before[1]).run
      end
    end

    def run_task
      task
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
anvil-core-0.0.1.pre.alpha.3 lib/anvil/task.rb
anvil-core-0.0.1.pre.alpha.2 lib/anvil/task.rb