Module: Tins::Concern::ModuleMixin
- Included in:
- Module
- Defined in:
- lib/tins/xt/concern.rb
Overview
This implementation relies on Thread.current which makes it
ModuleMixin provides thread-local storage for concern configuration.
This mixin adds methods to any module that includes it, allowing for configuration of concerns through thread-local storage. The configuration is stored in the current thread’s context and persists during the execution of code that uses this concern.
thread-safe but scoped to individual threads.
Instance Method Summary collapse
-
#tins_concern_args ⇒ Array?
Retrieves the current concern configuration arguments.
-
#tins_concern_configure(*args) ⇒ Module
Configures the module with the given arguments and returns self.
Instance Method Details
#tins_concern_args ⇒ Array?
Retrieves the current concern configuration arguments.
This method fetches the arguments that were previously set using #tins_concern_configure. If no configuration has been set, it returns nil.
56 57 58 |
# File 'lib/tins/xt/concern.rb', line 56 def tins_concern_args Thread.current[:tin_concern_args] end |
#tins_concern_configure(*args) ⇒ Module
Configures the module with the given arguments and returns self.
This method stores the provided arguments in thread-local storage, making them available via #tins_concern_args. It’s designed to be chainable (returns self).
41 42 43 44 |
# File 'lib/tins/xt/concern.rb', line 41 def tins_concern_configure(*args) Thread.current[:tin_concern_args] = args self end |