Module: PreAndPostInitialize::ClassInstance

Included in:
PreAndPostInitialize
Defined in:
lib/pre_and_post_initialize/class_instance.rb

Overview

Adds calls to #pre_initialize and #post_initialize before and after call to #initialize.

Instance Method Summary collapse

Instance Method Details

#initialize(any_arg, ...) ⇒ Object

Adds calls to #pre_initialize and #post_initialize before and after call to #initialize.

Parameters:

  • any_arg (Object)

    Any arguments can be used for initialize. No arguments are expected here, but any will be passed to super.



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/pre_and_post_initialize/class_instance.rb', line 22

def new( *args, & block )

  instance = allocate

  instance.instance_eval do
    pre_initialize( *args, & block )
    initialize( *args, & block )
    post_initialize( *args, & block )
  end
  
  return instance
  
end