Module: Toys::Mixin::ModuleMethods

Defined in:
toys-core/lib/toys/mixin.rb

Overview

Defined in the toys-core gem

Methods that will be added to a mixin module object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#inclusionProc

The inclusion proc for this mixin. This block is evaluated in the tool class immediately after the mixin is included, and is passed any arguments provided to the include directive.

Returns:

  • (Proc)

    The inclusion procedure for this mixin.



153
154
155
# File 'toys-core/lib/toys/mixin.rb', line 153

def inclusion
  @inclusion
end

#initializerProc

The initializer proc for this mixin. This proc is evaluated in the runtime context before execution, and is passed any arguments provided to the include directive. It can perform any runtime initialization needed by the mixin.

Returns:

  • (Proc)

    The iniitiliazer for this mixin.



131
132
133
# File 'toys-core/lib/toys/mixin.rb', line 131

def initializer
  @initializer
end

Instance Method Details

#on_include(&block) ⇒ self

Set an inclusion proc for this mixin. This block is evaluated in the tool class immediately after the mixin is included, and is passed any arguments provided to the include directive.

Parameters:

  • block (Proc)

    Sets the inclusion proc.

Returns:

  • (self)


141
142
143
144
# File 'toys-core/lib/toys/mixin.rb', line 141

def on_include(&block)
  self.inclusion = block
  self
end

#on_initialize(&block) ⇒ self

Set the initializer for this mixin. This block is evaluated in the runtime context before execution, and is passed any arguments provided to the include directive. It can perform any runtime initialization needed by the mixin.

Parameters:

  • block (Proc)

    Sets the initializer proc.

Returns:

  • (self)


118
119
120
121
# File 'toys-core/lib/toys/mixin.rb', line 118

def on_initialize(&block)
  self.initializer = block
  self
end