Module: PreInitialize

Defined in:
lib/shattered_support/pre_initialize.rb

Overview

:nodoc:all

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Constant Summary collapse

BEFORE_INIT_CALL_VALUES =
:before_init_call_values
BEFORE_INIT_SET_VALUES =
:before_init_set_values

Class Method Summary collapse

Class Method Details

.append_features(base) ⇒ Object



2
3
4
5
6
# File 'lib/shattered_support/pre_initialize.rb', line 2

def self.append_features(base)
  super
  base.extend(ClassMethods)
  base.send(:include, InstanceMethods)
end

.included(mod) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/shattered_support/pre_initialize.rb', line 8

def self.included(mod)
  return if mod == Object # This is to allow include Shattered::Timer at the top of files
  class << mod
    # This is overwritten to allow for a pre_initialize before initialize

    def new(*options) #:nodoc

      new_base = allocate
      new_base.pre_initialize
      new_base.send(:initialize, *options)
      return new_base
    end            
  end
end