Module: Toys::Mixin::ModuleMethods

Defined in:
core-docs/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

#inclusion=(value) ⇒ Proc

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.

You can also set the inclusion proc by passing a block to #on_include.

Returns:

  • (Proc)

    The inclusion procedure for this mixin.



144
145
146
# File 'core-docs/toys/mixin.rb', line 144

def inclusion=(value)
  @inclusion = value
end

#initializer=(value) ⇒ Proc

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.

You can also set the initializer proc by passing a block to #on_initialize.

Returns:

  • (Proc)

    The initializer for this mixin.



121
122
123
# File 'core-docs/toys/mixin.rb', line 121

def initializer=(value)
  @initializer = value
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)


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

def on_include(&block)
  # Source available in the toys-core gem
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)


106
107
108
# File 'core-docs/toys/mixin.rb', line 106

def on_initialize(&block)
  # Source available in the toys-core gem
end