Class: Object
- Inherits:
- BasicObject
- Includes:
- Full, Tins::AskAndSend, Tins::Attempt, Tins::BlockSelf, Tins::CasePredicate, Tins::Complete, Tins::DeepDup, Tins::Deflect, Tins::Eigenclass, Tins::Expose, Tins::IfPredicate, Tins::Interpreter, Tins::Null::Kernel, Tins::P, Tins::RequireMaybe, Tins::Responding, Tins::TempIO, Tins::ThreadGlobal, Tins::ThreadLocal, Tins::To
- Defined in:
- lib/tins/xt/ask_and_send.rb,
lib/tins/xt/attempt.rb,
lib/tins/xt/case_predicate.rb,
lib/tins/xt/complete.rb,
lib/tins/xt/deep_dup.rb,
lib/tins/xt/dslkit.rb,
lib/tins/xt/expose.rb,
lib/tins/xt/full.rb,
lib/tins/xt/if_predicate.rb,
lib/tins/xt/named.rb,
lib/tins/xt/null.rb,
lib/tins/xt/p.rb,
lib/tins/xt/require_maybe.rb,
lib/tins/xt/responding.rb,
lib/tins/xt/temp_io.rb,
lib/tins/xt/to.rb
Instance Method Summary collapse
-
#named(name, method, *args) {|Object| ... } ⇒ Object
Adds a dynamically created method to the object instance.
Methods included from Tins::To
Methods included from Tins::TempIO
Methods included from Tins::Responding
Methods included from Tins::RequireMaybe
Methods included from Tins::P
Methods included from Tins::Null::Kernel
Methods included from Tins::IfPredicate
Methods included from Tins::Expose
Methods included from Tins::BlockSelf
Methods included from Tins::Eigenclass
#eigenclass_class_eval, #eigenclass_eval
Methods included from Tins::Deflect
#deflect, deflect?, #deflect?, #deflect_start, #deflect_stop
Methods included from Tins::ThreadLocal
#instance_thread_local, #thread_local
Methods included from Tins::Interpreter
#interpret, #interpret_with_binding
Methods included from Tins::ThreadGlobal
#instance_thread_global, #thread_global
Methods included from Tins::DeepDup
Methods included from Tins::Complete
Methods included from Tins::CasePredicate
Methods included from Tins::Attempt
#attempt, #compute_duration_base, #interpret_sleep, #sleep_duration
Methods included from Tins::AskAndSend
#ask_and_send, #ask_and_send!, #ask_and_send_or_self, #ask_and_send_or_self!
Instance Method Details
#named(name, method, *args) {|Object| ... } ⇒ Object
Adds a dynamically created method to the object instance. The method will call the specified method
with optional args
and combine any provided named_block
with runtime blocks.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tins/xt/named.rb', line 35 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 extend m end |