Class: Datacraft::Instruction

Inherits:
Object
  • Object
show all
Includes:
Context
Defined in:
lib/datacraft/instruction.rb

Overview

Building Instruction

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Context

#consumers, #options, #post_hooks, #pre_hooks, #sources, #tweakers, #validate

Constructor Details

#initializeInstruction

Returns a new instance of Instruction.



7
8
9
10
11
# File 'lib/datacraft/instruction.rb', line 7

def initialize
  options[:parallel] = false
  options[:benchmark] = false
  options[:n_threads] = 8
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



5
6
7
# File 'lib/datacraft/instruction.rb', line 5

def context
  @context
end

Instance Method Details

#from(klass, *initialization_params) ⇒ Object



17
18
19
# File 'lib/datacraft/instruction.rb', line 17

def from(klass, *initialization_params)
  sources << Source.new(klass: klass, args: initialization_params)
end

#post_build(&block) ⇒ Object



29
30
31
# File 'lib/datacraft/instruction.rb', line 29

def post_build(&block)
  post_hooks << Hook.new(block: block)
end

#pre_build(&block) ⇒ Object



13
14
15
# File 'lib/datacraft/instruction.rb', line 13

def pre_build(&block)
  pre_hooks << Hook.new(block: block)
end

#set(key, value) ⇒ Object



33
34
35
# File 'lib/datacraft/instruction.rb', line 33

def set(key, value)
  options[key.to_sym] = value
end

#to(klass, *initialization_params) ⇒ Object



25
26
27
# File 'lib/datacraft/instruction.rb', line 25

def to(klass, *initialization_params)
  consumers << Consumer.new(klass: klass, args: initialization_params)
end

#tweak(klass = nil, *initialization_params, &block) ⇒ Object



21
22
23
# File 'lib/datacraft/instruction.rb', line 21

def tweak(klass = nil, *initialization_params, &block)
  tweakers << Tweaker.new(klass: klass, args: initialization_params, block: block)
end