Class: Rivendell::Import::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/rivendell/import/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task) ⇒ Context

Returns a new instance of Context.



6
7
8
# File 'lib/rivendell/import/context.rb', line 6

def initialize(task)
  @task = task
end

Instance Attribute Details

#taskObject (readonly)

Returns the value of attribute task.



4
5
6
# File 'lib/rivendell/import/context.rb', line 4

def task
  @task
end

Instance Method Details

#log(message) ⇒ Object



23
24
25
# File 'lib/rivendell/import/context.rb', line 23

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

#notify(target, options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/rivendell/import/context.rb', line 16

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

#run(&block) ⇒ Object



27
28
29
# File 'lib/rivendell/import/context.rb', line 27

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

#with(expression) ⇒ Object



12
13
14
# File 'lib/rivendell/import/context.rb', line 12

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