Class: Module
- Includes:
- CacheMethods, Tins::Annotate, Tins::ClassMethod, Tins::Concern::ModuleMixin, Tins::Constant, Tins::DSLAccessor, Tins::Delegate, Tins::Deprecate, Tins::FromModule, Tins::Implement, Tins::ParameterizedModule
- Defined in:
- lib/tins/xt/concern.rb,
lib/tins/memoize.rb,
lib/tins/xt/annotate.rb,
lib/tins/xt/deprecate.rb,
lib/tins/xt/dslkit.rb,
lib/tins/xt/implement.rb,
lib/tins/xt/named.rb
Overview
Extends the core Module class with the concern functionality.
This line makes the concern configuration methods available to all modules in the system, allowing any module to be configured as a concern.
Direct Known Subclasses
Constant Summary
Constants included from Tins::Implement
Constants included from Tins::Delegate
Instance Method Summary collapse
-
#memoize_function(*function_ids) ⇒ Symbol+
deprecated
Deprecated.
Use ‘memoize function:` from the mize gem instead.
-
#memoize_method(*method_ids) ⇒ Symbol+
deprecated
Deprecated.
Use ‘memoize method:` from the mize gem instead.
-
#named(name, method, *args) {|Object| ... } ⇒ Module
Adds a dynamically created method to all instances of the class.
Methods included from Tins::Implement
#implement, #implement_in_submodule
Methods included from Tins::FromModule
Methods included from Tins::ParameterizedModule
Methods included from Tins::Delegate
Methods included from Tins::ClassMethod
#class_attr_accessor, #class_attr_reader, #class_attr_writer, #class_define_method
Methods included from Tins::Eigenclass
#eigenclass_class_eval, #eigenclass_eval
Methods included from Tins::DSLAccessor
#dsl_accessor, #dsl_lazy_accessor, #dsl_reader
Methods included from Tins::Constant
Methods included from Tins::Deprecate
Methods included from Tins::Concern::ModuleMixin
#tins_concern_args, #tins_concern_configure
Methods included from Tins::Annotate
Instance Method Details
#memoize_function(*function_ids) ⇒ Symbol+
Use ‘memoize function:` from the mize gem instead.
Memoize a function (class method) so that its return value is cached based only on the arguments, shared across all instances of the class.
108 109 110 111 112 113 114 115 116 |
# File 'lib/tins/memoize.rb', line 108 def memoize_function(*function_ids) warn "[DEPRECATION] `memoize_function` is deprecated. Please use `memoize function:` from mize gem." function_ids.extend(ExtractLastArgumentOptions) function_ids, opts = function_ids. function_ids.each do |function| memoize function:, **opts.slice(:freeze) end function_ids.size == 1 ? function_ids.first : function_ids end |
#memoize_method(*method_ids) ⇒ Symbol+
Use ‘memoize method:` from the mize gem instead.
Memoize a method so that its return value is cached based on the arguments and the object instance. Each instance maintains its own cache.
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/tins/memoize.rb', line 87 def memoize_method(*method_ids) warn "[DEPRECATION] `memoize_method` is deprecated. Please use `memoize method:` from mize gem." method_ids.extend(ExtractLastArgumentOptions) method_ids, opts = method_ids. method_ids.each do |method| memoize method:, **opts.slice(:freeze) end include CacheMethods method_ids.size == 1 ? method_ids.first : method_ids end |
#named(name, method, *args) {|Object| ... } ⇒ Module
Adds a dynamically created method to all instances of the class. The method will call the specified method
with optional args
and combine any provided named_block
with runtime blocks.
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/tins/xt/named.rb', line 64 def named(name, method, *args, &named_block) name = name.to_sym m = Tins::Named.new { define_method(name) do |*rest, &block| block = named_block if named_block __send__(method, *(args + rest), &block) end } if m.respond_to?(:set_temporary_name) m.set_temporary_name "#{m.class} for method #{name.inspect}" end include m end |