Class: DataMiner::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/data_miner/step.rb,
lib/data_miner/step/await.rb,
lib/data_miner/step/derive.rb,
lib/data_miner/step/import.rb,
lib/data_miner/step/callback.rb,
lib/data_miner/step/associate.rb

Direct Known Subclasses

Associate, Await, Callback, Derive, Import

Defined Under Namespace

Classes: Associate, Await, Callback, Derive, Import

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, number, options = {}) {|_self| ... } ⇒ Step

Returns a new instance of Step.

Yields:

  • (_self)

Yield Parameters:



7
8
9
10
11
12
13
14
15
# File 'lib/data_miner/step.rb', line 7

def initialize(configuration, number, options = {}, &block)
  @configuration = configuration
  @number = number
  @options = options
  yield self if block_given? # pull in attributes
  attributes.affect_all_content_columns!(self, :except => options[:except]) if options[:affect_all] == :content_columns
  affected_attributes.each { |attr| attr.options_for_step[self][:callback] = options[:callback] } if options[:callback]
  all_attributes.each { |attr| attr.options_for_step[self][:name_in_source] = attr.name_in_source(self).upcase } if options[:headers] == :upcase # TODO remove
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



3
4
5
# File 'lib/data_miner/step.rb', line 3

def configuration
  @configuration
end

#numberObject

Returns the value of attribute number.



3
4
5
# File 'lib/data_miner/step.rb', line 3

def number
  @number
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/data_miner/step.rb', line 3

def options
  @options
end

Instance Method Details

#affect(attr_name, attr_options = {}) ⇒ Object Also known as: store



55
56
57
# File 'lib/data_miner/step.rb', line 55

def affect(attr_name, attr_options = {})
  attributes.affect! self, attr_name, attr_options
end

#affected_attributesObject



39
40
41
# File 'lib/data_miner/step.rb', line 39

def affected_attributes
  @affected_attributes ||= attributes.all_affected_by self
end

#all_attributesObject



47
48
49
# File 'lib/data_miner/step.rb', line 47

def all_attributes
  @all_attributes ||= attributes.all_for self
end

#awaiting?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/data_miner/step.rb', line 21

def awaiting?
  !options[:awaiting].nil?
end

#inspectObject



25
26
27
# File 'lib/data_miner/step.rb', line 25

def inspect
  "Step(#{klass} #{variant.to_s.camelcase} #{number})"
end

#key(attr_name, attr_options = {}) ⇒ Object



51
52
53
# File 'lib/data_miner/step.rb', line 51

def key(attr_name, attr_options = {})
  attributes.key! self, attr_name, attr_options
end

#key_attributesObject



43
44
45
# File 'lib/data_miner/step.rb', line 43

def key_attributes
  @key_attributes ||= attributes.all_keys_for self
end

#map_to_attrs(method) ⇒ Object



60
61
62
# File 'lib/data_miner/step.rb', line 60

def map_to_attrs(method)
  affected_attributes.map { |attr| attr.send method, self }.compact
end

#perform(options = {}) ⇒ Object



33
34
35
36
37
# File 'lib/data_miner/step.rb', line 33

def perform(options = {})
  return if awaiting? and !options[:force]
  affected_attributes.each { |attr| attr.perform self }
  $stderr.puts "performed #{signature}"
end

#signatureObject



29
30
31
# File 'lib/data_miner/step.rb', line 29

def signature
  "#{klass} step #{number}: #{variant}"
end

#variantObject



17
18
19
# File 'lib/data_miner/step.rb', line 17

def variant
  self.class.name.demodulize.underscore.to_sym
end