module Toys::Mixin::ModuleMethods

Methods that will be added to a mixin module object.

Attributes

inclusion[RW]

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.

@return [Proc] The inclusion procedure for this mixin.

initializer[RW]

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.

@return [Proc] The iniitiliazer for this mixin.

Public Instance Methods

on_include(&block) click to toggle source

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.

@param block [Proc] Sets the inclusion proc. @return [self]

# File lib/toys/mixin.rb, line 137
def on_include(&block)
  self.inclusion = block
  self
end
on_initialize(&block) click to toggle source

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.

@param block [Proc] Sets the initializer proc. @return [self]

# File lib/toys/mixin.rb, line 114
def on_initialize(&block)
  self.initializer = block
  self
end