Method: ClassNotes::Notebook#wrap_methods

Defined in:
lib/class_notes/notebook.rb

#wrap_methods(*meths) ⇒ Object

Returns nil.

Parameters:

  • meths

    the methods to wrap

Returns:

  • nil



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/class_notes/notebook.rb', line 31

def wrap_methods(*meths)
  meths.each { |meth|
    m = method(meth)
    define_singleton_method(meth) { |*args, &block|
      parent    = add_note
      child     = add_note.({title: meth.to_s, args: args})
      @add_note = ClassNotes.note_taker(child)

      results   = super(*args, &block)
      @add_note = parent

      child.results = results

      results
    }
  }
end