Module: PreInitialize::ClassMethods
- Defined in:
- lib/shattered_support/pre_initialize.rb
Instance Method Summary collapse
-
#before_init_call(function, *arguments) ⇒ Object
All shattered objects have a pre_initialization phase.
-
#before_init_set(variable, options = {}) ⇒ Object
In the pre_initialization phase (see #before_init_call), send an object a bunch of sets.
Instance Method Details
#before_init_call(function, *arguments) ⇒ Object
All shattered objects have a pre_initialization phase. Use this to specify that a function should be called when the object is created.
Example:
class BulletModel < ShatteredModel::Base
before_init_call(:calculate_trajectory, v(0,0,0), v(0,0,1))
def calculate_trajectory
#called before initialize is
end
end
52 53 54 |
# File 'lib/shattered_support/pre_initialize.rb', line 52 def before_init_call(function, *arguments) self.write_inheritable_array(BEFORE_INIT_CALL_VALUES, [[function, [*arguments]]]) end |
#before_init_set(variable, options = {}) ⇒ Object
In the pre_initialization phase (see #before_init_call), send an object a bunch of sets.
This is used in actor, camera, mesh, and virtually everywhere to support the format of:
mesh "ruby", :position => v(1,0,0)
becomes
before_init_set( :ruby, {:position => v(1,0,0) } )
becomes
ruby.position=v(1,0,0)
when the obect is initialized.
37 38 39 |
# File 'lib/shattered_support/pre_initialize.rb', line 37 def before_init_set(variable, ={}) self.write_inheritable_array(BEFORE_INIT_SET_VALUES, [[ variable, ]] ) end |