Class: Machinist::Lathe

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#after_make_callbackObject (readonly)

Returns the value of attribute after_make_callback.



8
9
10
# File 'lib/machinist_callbacks.rb', line 8

def after_make_callback
  @after_make_callback
end

#before_make_callbackObject (readonly)

Returns the value of attribute before_make_callback.



8
9
10
# File 'lib/machinist_callbacks.rb', line 8

def before_make_callback
  @before_make_callback
end

Class Method Details

.run_with_before_make(*args) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/machinist_callbacks.rb', line 20

def run_with_before_make(*args)
  lathe = run_without_before_make(*args)
  if callback = lathe.object.instance_variable_get(:@before_make_callback)
    lathe.object.instance_eval(&callback)
  end
  lathe
end

Instance Method Details

#after_make(&callback) ⇒ Object



14
15
16
# File 'lib/machinist_callbacks.rb', line 14

def after_make(&callback)
  object.instance_variable_set(:@after_make_callback, callback)
end

#before_make(&callback) ⇒ Object



10
11
12
# File 'lib/machinist_callbacks.rb', line 10

def before_make(&callback)
  object.instance_variable_set(:@before_make_callback, callback)
end