Sha256: eb3cd543618763c3c6d8e684201b1dad30d00cc43fcc52a9a76742c370d75349

Contents?: true

Size: 627 Bytes

Versions: 5

Compression:

Stored size: 627 Bytes

Contents

module Rivendell::Import
  class Context

    attr_reader :task

    def initialize(task)
      @task = task
    end

    delegate :file, :cart, :logger, :to => :task

    def with(expression)
      yield if file.match expression
    end

    def notify(target, options = {})
      Rivendell::Import::Notifier::Base.notify(target, options).tap do |notifier|
        logger.debug "Will notify with #{notifier.inspect}"
        task.notifiers << notifier
      end
    end

    def log(message)
      logger.info message if message
    end

    def run(&block)
      instance_exec file, &block if block_given?
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rivendell-import-1.04 lib/rivendell/import/context.rb
rivendell-import-1.03 lib/rivendell/import/context.rb
rivendell-import-1.02 lib/rivendell/import/context.rb
rivendell-import-1.01 lib/rivendell/import/context.rb
rivendell-import-0.10 lib/rivendell/import/context.rb