Class: Bricolage::DataSourceTask

Inherits:
Object
  • Object
show all
Defined in:
lib/bricolage/script.rb

Defined Under Namespace

Classes: Action

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ds) ⇒ DataSourceTask

Returns a new instance of DataSourceTask.



65
66
67
68
# File 'lib/bricolage/script.rb', line 65

def initialize(ds)
  @ds = ds
  @actions = []
end

Instance Attribute Details

#dsObject (readonly)

Returns the value of attribute ds.



70
71
72
# File 'lib/bricolage/script.rb', line 70

def ds
  @ds
end

Instance Method Details

#bind(*args) ⇒ Object



72
73
74
75
76
# File 'lib/bricolage/script.rb', line 72

def bind(*args)
  @actions.each do |action|
    action.bind(*args)
  end
end

#runObject



78
79
80
81
82
83
84
85
86
# File 'lib/bricolage/script.rb', line 78

def run
  result = nil
  @ds.open_for_batch {
    @actions.each do |action|
      result = action.run
    end
  }
  result
end

#sourceObject



88
89
90
91
92
93
94
# File 'lib/bricolage/script.rb', line 88

def source
  buf = StringIO.new
  @actions.each do |action|
    buf.puts action.source
  end
  buf.string
end