Module: PreAndPostInitialize::ObjectInstance

Defined in:
lib/pre_and_post_initialize/object_instance.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#post_initialize(any_arg, ...) ⇒ Object

Permits activity to be defined after all initialization activity.

Parameters:

  • any_arg (Object)

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



44
45
46
47
48
# File 'lib/pre_and_post_initialize/object_instance.rb', line 44

def post_initialize( *args, & block )
  # call to super in case we extend Class or Module, so we can stack calls to post_initialize
  super if defined?( super )
  # nothing here - subclasses define
end

#pre_initialize(any_arg, ...) ⇒ Object

Permits activity to be defined prior to any initialization activity. This can be useful

if initialization activity may depend on a particular feature, such as instance registration,
prior to activity occuring that queries or otherwise implicates its identity/definition.

Parameters:

  • any_arg (Object)

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



24
25
26
27
28
# File 'lib/pre_and_post_initialize/object_instance.rb', line 24

def pre_initialize( *args, & block )
  # call to super in case we extend Class or Module, so we can stack calls to pre_initialize
  super if defined?( super )
  # nothing here - subclasses define
end